I mainly use Windows but need to work on Linux for development. One way to use Linux on my Windows machine is using VirtualBox. I used to have CentOS destop distribution but it was too much as I didn’t need most of its desktop features. A Linux server is good for this purpose but it was quite out of hand until I found out a guest machine can be connected via SSH and RStudio Server. In this post, a quick way to connect to a Ubuntu guest via SSH using Putty and RStudio Server is illustrated. Also a way to transfer a file between the machines using WinSCP is demonstrated.

SSH

Once a VM is installed, it is necessary to set up two network adapters: Bridged Adapter and Host-only Adapter. My setup is shown below. (See further details here.)

center

Then OpenSSH Server should be installed in the guest machine and connection via port 22 should be allowed - it is the default SSH port. This job can easily be done as following.

sudo apt-get update

sudo apt-get install openssh-server

sudo ufw allow 22

The ip address of the guest can be checked by ip addr and it can be used to set up a session in Putty (user-name@ip-address).

center

Setting up a Putty session is as simple as the following.

center

Once the above steps work well, it is possible to connect to the guest via SSH.

center

WinSCP

Transferring a file to and from a guest can be done easily using WinSCP. The session login window is quite intuitive and mine is shown below.

center

Once logged on, a file can be dragged and dropped between the machines.

center

RStudio Server

Putty Terminal may or may not be good to work on and it may be not if R is used interactively. In this case, RStudio server can be a good option.

As the lastest version of R is not included in Ubuntu LTS, it is good to install the latest version as recommended in the download page. I added the following line in /etc/apt/sources.list.

deb https://<my.favorite.cran.mirror>/bin/linux/ubuntu trusty/

When I tried to update the package by sudo apt-get update, however, GPG error was encountered, indicating NO_PUBKEY 51716619E084DAB9. After some search, I was able to resolve it by the following. (See this)

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 51716619E084DAB9

sudo apt-get update

Then I was able to install R and the development packages.

sudo apt-get install r-base

sudo apt-get install r-base-dev

If you need to install a package that requires curl and xml libraries (eg devtools), they should be installed.

sudo apt-get install libcurl4-openssl-dev libxml2-dev

Then Rstudio Server can be connected via a browser of the host machine. Type guest-ip-address:8787 in the address bar. The guest machine’s user name and password can be used to log on. Mine is shown below.

center