The Prerequisites:

  • A Microsoft Azure account ( You can use a free trial if you do not have one)
  • An existing Linux Virtual Machine in a resource group.

By default, connecting to a Linux VM in Azure is usually done over an SSH Connection.

In this post, I 'am going to show you how to RDP/ Remote Desktop into a Linux VM (Ubuntu) so that you can manage it the traditional Windows way.

We are going to use Xfce as our desktop environment for this scenario. There are many desktop environments, and you can install any of your choices. However, my choice for Xfce is because it's a lightweight desktop environment that reserves resources. And then, we shall also use xdrp, which is an open-source RDP manager.

Step 1

SSH into your Linux virtual machine. Note that you can also open a serial connection to your Azure VM instead of an SSH connection, As shown below.

The serial console connection is at the Support + Troubleshooting section of your Azure VM Instance.
You will need to press enter at the serial console once it's done loading since it doesn't immediately show the login prompt.

Step 2

Once logged in, we then run the command below to install Xfce.

sudo apt-get update

sudo apt-get -y install xfce4

"For CentOS users, you will need to use the yum package manager to install xfce"

During the installation, a screen will pop up prompting you to select the preferred display manager. You can select gdm3 to proceed with the installation.

When it's done installing, we then run the commands below to install and enable our remote desktop connection protocol for Linux, xrdp.

sudo apt-get -y install xrdp

sudo systemctl enable xrdp

When that is complete, we configure xrdp to connect to our desktop environment session as shown in the command below and then finalize by restarting the xrdp service.

echo xfce4-session >~/.xsession

sudo service xrdp restart

Step 4

The last step involves creating a network security rule to allow RDP traffic into our VM, and we can use the command below to achieve that through the Azure cloud shell.

Replace the resource-group name with yours; in this case, mine is tech-talk-rg1, and the name of my VM is ubuntu-node01. RDP connects over port 3389, and this is the port we want to allow access to.

Next, update the session manager configuration to use the xfce4-session configuration.

sudo update-alternatives --config x-session-manager

In this case, select option 3.

Once that is complete, we then connect to our VM using the usual windows remote desktop connection console, and we get an RDP session as shown below. Click ok to login