Remote desktop to Azure Virtual Machine running Ubuntu

A Linux server on Azure is a great combination but there are some extra steps to be able to remote desktop into a Linux box. This article will walk through how to get remote desktop setup on an Ubuntu Linux server.

The following prerequisites are assumed.

PreReq:
Azure account
PuTTY for SSH connection
Create an Azure Virtual machine
Set up endpoints on an Azure virtual machine

Step 1: Create an Ubuntu Server Virtual Machine

Click in the portal to create a new Virtual Machine from Gallery.

In the “Choose an Image” select an Ubuntu Server. If you choose 12.0 you can use the desktop that comes with Ubuntu. If you choose a higher version you will need to do Step 5 to install a desktop.

Fill in the Virtual machine information making sure to enable SSH either through certificate or password. I’d recommend using a password if you are still getting familiar with SSH

Walk through the rest of the Virtual Machine wizard and create the Virtual machine.

Step 2: SSH Connect to machine using Putty

To configure the Azure machine SSH connect to it with Putty using the DNS name of your Virtual Machine and SSH password that you set during Virtual machine creation.

Step 3: Setup the Root password

This step is not strictly required for Remote desktop setup but you should always setup a root password on a new Linux box.

In your Putty window run the following command and set a password for root.

sudo passwd root

Step 4: Configure Remote desktop with SSH

To configure the Azure machine SSH connect to it with Putty using the DNS name of your Virtual Machine and SSH password that you set during Virtual machine creation.

xrdp requires tightvncserver so tightvncserver should be installed first.

In your Putty window run the following commands:
sudo apt-get install tightvncserver
sudo apt-get install xrdp

Step 5: Install a Desktop

To use a Remote Desktop, we actually need to have a Desktop. If you’ve installed Ubuntu 12.0 you can skip this step. For Ubuntu 14 Gnome 3 will crash when connecting with remote services.

The desktops I’ve found to work well are MATE and Xfce4. My personal preference is MATE but I’d recommend you try out both and see which one you like.

There is also an extra step that we need to set which desktop to use when the xrdp service connection is made.

For MATE run the following commands in PUTTY:

sudo apt-get install mate
echo “mate-session” > ~/.xsession
chmod +x ~/.xsession
sudo systemctl restart xrdp.service

To try out Xfce4 run these commands in PUTTY:

sudo apt-get install xfce4-session
echo “startxfce4” > ~/.xsession
chmod +x ~/.xsession
sudo systemctl restart xrdp.service

Step 6: Add the RPD endpoint

In the Azure Portal add an RPD endpoint for your Virtual machine.

Step 7: Make the Connection

All that’s left is to Remote Desktop to the machine.

If you are on a Windows machine start the Remote Desktop Connection Exe.

WindowsKey – r to bring run the “Run As Dialog”
Type in “mstc” and then click the OK button.
The Remote Desktop window will open. Type in the DNS name of the virtual machine and connect using the same username and password used for the SSH (Putty) connection in step2.

Enjoy.

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *