Install a desktop environment GUI on Ubuntu Server in Azure.

All the Linux server Virtual Machine images on Azure don’t come with a desktop environment, which is obviously usually the right thing to do with a server. There’s usually no need for a desktop environment as all operations can be done from the CLI via ssh. However, maybe you need a desktop environment for another reason. For example, setting up Azure Lab Services for class rooms, maybe those Virtual Machines need a desktop enviroment for lessons in your lab.

The plan

We’re going to go through installing a desktop environment and setting up RDP to allow us to connect to our Virtual Machine.

  1. Install the xfce desktop environment
  2. Install and configure Xrdp
  3. Disable the compositor

1. Install the xfce desktop environment

First before we get started let’s make sure that our VM is completely up to date by running apt-get update and apt-get upgrade.

sudo apt-get update 
sudo apt-get upgrade

Next let’s install xfce, xfce is a fairly lightweight but still very user friendly desktop environment. Of course you can install Unity or KDE or whatever floats your boat, but to keep resources free for other operations I’ve chosen to use a lightweight desktop environment.

The –no-install-recommends flag tells apt-get to not consider recommended packages to install, this ensures we only get the minimal packages neeeded to get xfce running.

sudo apt-get install -y xfce4 --no-install-recommends

1.1 Install KDE desktop environment

sudo apt-get install --no-install-recommends kubuntu-desktop

2. Install and configure Xrdp

Xrdp is an open source package that allows us to login to remote Virtual Machines using RDP (Microsoft Remote Desktop Protocol).

You can view the project on github

Install Xrdp with apt-get

sudo apt-get install -y xrdp

Once it’s installed, Xrdp should start automatically, check that it is running by typing:

sudo systemctl status xrdp

Configure Xrdp

Xrdp uses the /etc/ssl/private/ssl-cert-snakeoil.key file, which is only readable by users that are members of the ssl-cert group

Add xrdp user to the ssl-cert group

sudo adduser xrdp ssl-cert  
sudo systemctl restart xrdp

3. Disable the Compositor

The refresh rate on the RDP session is pretty slow, XFCE isn’t TOO bad (Unity & KDE were pretty un-usable for me), disabling the compositor makes it way better so I suggest doing just that.

You can disable the compositor via the GUI or via the terminal.

Terminal

xfconf-query -c xfwm4 -p /general/use_compositing -t bool -s false --create

GUI

Run Window Manager Tweaks

xfwm4-tweaks-settings

Click on Compositor and click disable