Normally when a Linux Virtual Machine is created on Azure, we’re given just the core installation. That is, the VM is accessed through a command line over an SSH session. Here I’m going to try setting up an environment on a Linux VM that’s accessible through the Remote Desktop client.
The general principle here is that we create a standard Linux virtual machine in Azure, and on that we install the desktop manager, interface and a Remote Desktop server. Hopefully we’ll be able to connect the Remote Desktop client to this the same way we would a Windows VM.
First thing’s first: Most the configuration is done in the VM’s command line, so the local machine must have either BASH or PuTTY, or a program that enables an SSH session. Also, it helps to understand something about the architecture, dependencies and configuration files of a Linux system, but that’s not essential here.
The remote system here is an Ubuntu 16.04 Virtual Machine, and I’ve selected the cheapest and most basic pricing option.
An SSH Session
After the VM has been ceated, deployed and started, clicking the ‘Connect‘ link in the Azure Portal will show which IP address to point the SSH client to.
So, let’s try this by running PuTTY and initiating an SSH session to the VM’s IP address. After entering my username and password, and switching to the root account, I get the following:
Now we’re in business, and I can check for a package manager (ideally APT), and whether the X11, desktop manager, desktop interface and XRDP packages are available. This should be the case for any Debian-based installation. Before proceeding, run ‘
#apt-get update‘ to avoid broken header problems.
Desktop Manager and Environment
Initially I was going to install the MATE desktop, but running ‘
#apt-get install mate‘ indicated the components and dependencies amounted to over 1GB. I wanted something much smaller for demonstration purposes, so I chose XFCE instead, running ‘
#apt-get install xfce4‘. It’s always possible to install and switch between desktop managers later, if needed.
Despite the warning messages shown during installation, the desktop components will be installed.
Setting Up the XRDP Server
The next component required is a remote desktop server. This will be provided by XRDP, which is installed with:
#apt-get install xrdp
After installation, we can use ‘
#service xrdp status‘ to check whether the XRDP server is running. This is a useful command, as it enables us to stop and restart services at any point. The output should look something like this:
Every user on the system will need a .xsession configuration file in their home directories, to specify the default environmment to load when initiating an X11 session. Currently I’m logged in as root, so I need to navigate to my non-root home directory, and create this file containing the line ‘
xfce4-session‘ in it. The commands are:
And add a single line to the file:
A quicker way to do this as root from the current path would be:
#echo xfce4-session >/home/michael/.xsession
Now restart the XRDP server to load the changes.
#service xrdp restart
UPDATE: 300MB of the desktop manager and interface packages consist of dependencies common to MATE and XFCE. If you want to install the MATE desktop, run
#'apt-get install mate‘ and change the line in .xsession to ‘
Configuring the Azure Inbound Rule for RDP
At this point the VM should have a desktop manager and an RDP server running. Now we need to find the Remote Desktop server port, so Azure can be configured to allow connections to it.
It looks like the port we’re interested in here is 3389. In the Azure Portal, under the Network tab, add an Inbound Port Rule for ‘RDP’ – this will indeed be port 3389.
Now, the moment of truth. We’ll connect the Windows Remote Desktop client to the VM. And presto, the XFCE desktop.
And the MATE desktop over XRDP: