Establishing a remote connection to your Azure Virtual Machine via RDP
The following are the prerequisites for this tutorial:
Introduction to Cloud Computing
Read this article for an introduction to basic Cloud Computing aspects.
Virtual Machines on Microsoft Azure- A Detailed Guide for Beginners
Read this article to learn how to create a VM on Azure and configure it based on your needs.
Connecting to your VM via SSH on Microsoft Azure
Read this article to learn how to SSH into your VM on Microsoft Azure
Installing a Desktop Environment for your VM
Why do we have to install a separate desktop environment? Doesn’t Ubuntu already have one?
Notice that we are using an Ubuntu Server which isn’t the same as Ubuntu Desktop. The main difference between these two is that Ubuntu Desktop has a GUI while Ubuntu Server doesn’t. Both have the same kernels so you can run the same commands and perform the same tasks in both. Cloud Computing services typically don’t offer desktop environments because most people just use the server features to run their projects.
We will be installing xfce, a free and open-source desktop environment for Linux and BSD operating systems which is fast and lightweight while still being visually appealing and easy to use.
First, we’ll update all packages on our new VM. Type the following command in bash itself after establishing an SSH connection to the VM as shown in the previous article.
sudo apt-get update
After that, type the following command to install xfce onto your VM:
sudo apt-get -y install xfce4
This will take some time to get installed (it is a desktop environment after all). It might take at max 10–15 min depending on your internet and system.
Installing RDP server software on our VM
What is RDP?
Remote Desktop Protocol is a proprietary protocol developed by Microsoft which provides a user with a graphical interface to connect to another computer over a network connection. The user employs RDP client software for this purpose, while the other computer must run RDP server software.
Windows and Linux systems will already have an RDP client software preinstalled in their system. Windows has Remote Desktop Connection while Linux has Remmina.
After the installation of the desktop environment in the previous step, enter the following commands on bash while still being connected to the VM through the SSH connection we had established:
First we will install xrdp which is an RDP server software:
sudo apt-get -y install xrdp
We will then enter the following command to tell our VM to automatically start xrdp on system startup:
sudo systemctl enable xrdp
Run the following command to configure xrdp to use xfce as your desktop environment as follows:
echo xfce4-session >~/.xsession
Then restart xrdp to save your changes:
sudo service xrdp restart
Enabling RDP connection to VM by modifying NSGs
To allow Remote Desktop traffic to reach your Linux VM, a network security group rule needs to be created that allows TCP on port 3389 to reach your VM. Switch to PowerShell and type the following command:
az vm open-port — resource-group myResourceGroup — name myVM — port 3389
Replace myResourceGroup with the name of the resource group that you created for the VM and replace myVM with the name of your VM. After this you will be able to successfully access your VM through a remote desktop connection.
Opening our VM through the RDP client software
Open Remote Desktop Connection on Windows (or Remmina on Linux) and type in the Public IP address of your VM there and select the ‘Connect’ option. After this you will see a dialog box which says that it may not be safe to open an unknown VM and asks if you still want to make this connection. Select ‘OK’. Your RDP client software will then try to connect to your VM and will subsequently open it after a few seconds. You can play around a bit with your VM and try some commands on the terminal as well.