Accessing the Data Science Virtual Machine
Once the virtual machine is set up and started (by clicking “start” on the appropriate VM in the Azure portal) there are several ways to interface with it. The first is via the terminal (I am running Ubuntu 16.04 on both my local machine and the virtual machine). To connect to the virtual machine from the terminal, we can use secure shell, or SSH. This requires a set of keys which are used for encryption and decryption and keep the connection between the local and virtual machine secure. These keys are unique to your system, and they need to be generated. This can be done using the command line.
Generating ssh keys:
Option 1 is to use the terminal on your local machine. In Ubuntu, the following command will generate an RSA key pair (RSA is a method of encryption named after Rivest, Shamir and Adleman who first proposed it) with a length of 2048 bits:
ssh-keygen -t rsa -b 2048
Alternatively, the Azure command line interface (azure CLI) can be used. The Azure CLI is a command line service that can be installed to run from the existing terminal or it can also run in a web browser and is used to send commands directly to the virtual machine in an Azure-friendly syntax. To create the ssh key pair in Azure CLI:
az vm create –name VMname –resource-group RGname –generate-ssh-keys
Regardless of the method used to generate them, ssh key pairs are stored by default into
and to view the key the following bash command can be used
The key values displayed by this command should be stored somewhere secure for later use. The ssh keys enable access to the VM through the command line (local terminal or Azure CLI). Alternatively, the virtual machine can be configured with a desktop that can be accessed using a remote desktop client. This requires some further VM configuration:
To set up remote desktop
The ssh keys created earlier can be used to access the VM through the terminal. Then, the terminal can be used to install a desktop GUI to the VM. I chose the lightweight GUI LXDE to run on my Ubuntu VM. To install LXDE use the command:
sudo apt-get install lxde -y
To install the remote desktop support for LXDE:
sudo apt-get install xrdp -y
Then start XRDP running on the VM:
Then the VM needs to be configured to enable remote desktop. This cna be done via the Azure portal (portal.azure.com). Login using Azure username and password, start the VM by clicking “start” on the dashboard. Then navigate to the inbound security rules:
resource group > network security > inbound security rules > add >
A list of configuration options is then available, they should be updated to the following settings:
source port ranges: *
destination port ranges: 3389
Finally, a remote desktop client is required on the local machine. I chose to use X2Go client available from the Ubuntu software centre or can be installed in the terminal using apt-get. After The RDC is installed, the system is ready for remote access to the VM using a desktop GUI.
Remote Access to VM using Desktop GUI:
- The VM must first be started – this can be done via the Azure portal after logging in with the usual Azure credentials (username and password) and clicking “start” on the dashboard. Copy the VM IP addres to the clipboard.
- Open X2Go Client and comfigure a new session:
- Host = VM ip address
- Login = Azure login name
- SSH port: 22
- Session Type = XFCE
- These credentials can be saved under a named session so logging in subsequently just requires clicking on the session icon in X2Go (although the ip address for the VM is dynamic by default so will need updating each time).
- A LXDE GUI will open!
Remember that closing the remote desktop does not stop the Azure VM – the VM must be stopped by clicking “stop” on the dashboard on the Azure portal.