Using RDP to connect Azure Linux Virtual Machine

rdp-azure-linux-vm

In many instances, you need to connect to the Azure Linux Virtual Machine (vm) using the remote desktop protocol (RDP). It is a proprietary protocol from Microsoft to connect to the vm. It provides a way to login to the vm with a graphical user interface. Unlike windows vm, Linux vm doesn’t come up with the RDP enabled unless you install the distribution along with the desktop environment. It needs the following software packages to install into the server/workstation which you want to access

  • xRDP
  • Graphical shells like xfce, Gnome, KDE etc.

notes

It is worth mentioning that there are plenty of RDPs (xRDP, xVNC, etc.) available. Similarly, there are many graphical shells (GNome, KDE, xfce, etc.) also. You can choose them based on your preference. In this article, you will configure the xRDP and Xfce for Azure Linux vm with Ubuntu distribution.

Apart from the above two packages, you will also, make changes to the Azure Linux vm and network settings to use RDP. Let me put together the steps here

Create Azure Linux vm with ubuntu

You will use the Azure CLI command to create the Linux vm. The –generate-ssh-keys parameter generates the convoluted public and private key-pair for SSH connectivity. You can refer to the article Using SSH to connect Azure Linux vm from Windows to know more about the SSH.

Connect to the Azure Linux vm using SSH

You can connect to the vm using SSH. By default, the open-ssh is already installed in the vm. It allows you to change the password of the user azureuser. The password is necessary for login to the vm and installed the required software packages.

Install Xfce in the Azure Linux vm

It’s time to install the desktop environment a.k.a graphical shell. Let’s begin with update the repository and upgrade the existing packages and their dependencies. Afterward you will install the Xfce related packages. It helps to configure a desktop environment to the Azure Linux vm.

Install xRDP in the Azure Linux vm

After installing the Xfce packages, you will install xRDP. It helps to connect the Azure Linux vm using RDP.

Open the firewall port 3389 of Azure Linux vm

In general, firewall has a set of rules. It checks the information (from, to, protocol etc.) of the in-out bound data packets. The RDP connects through port 3389. You will open the firewall port 3389 of the Linux vm. You will use the ufw package which is known as Uncomplicated Firewall. Then add the port 3389 to allow traffic in the firewall. Please note, any change in the firewall requires to restart the ufw service

Open the port 3389 of the network security group

Network security group (nsg) is a kind of firewall of the Azure virtual network. There is always a default virtual network assigned to the Azure Linux vm. It checks the information (origin, target, protocol etc.) of the in-out bound data packets. You will open the port 3389 of the nsg to allow RDP communication to work.

RDP into the Azure Linux vm

This is the final step. It’s time to download the RDP from the Azure portal and connect to the Azure Linux vm. You can login to the Azure portal and go the the connect tab of the Linux vm. Alternatively you can also use RDP from your workstation by the public IP address of the Azure Linux vm. You will use the user azureuser and password to connect. You have already created the password at step 2.

Conclusion

After connecting to Azure Linux vm (with Ubuntu distribution), you can work inside the vm as if it is your workstation. You can try out other desktop environments like KDE, lxce, etc.
Please leave your feedback in the comment section below. I would be happy to help you. If you enjoyed reading this article, share it with your friends and colleagues!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.