fbpx

How to Setup an Ubuntu Linux VM in Azure with Remote Desktop (RDP) Access 1Some time back I wrote about doing Visual Studio development with an Azure Virtual Machine (VM). In that article, I showed how you can setup a Windows VM for Development purposes to extend your local development machine with the help of the cloud. In this article, I want to share some tips I’ve found in how to setup a Linux VM in Azure that you can use for similar purposes.

It’s worth noting that the steps to install RDP support outlined below will work with any Ubuntu Server instance; not just one running in Microsoft Azure. 🙂

Linux Support for Remote Desktop (RDP)

Normally, when you setup a Linux VM (perhaps Ubuntu Server) in Microsoft Azure, you can only connect to and remote into it via SSH. The reason this differs from a Windows VM in Azure; as Linux VMs do not support Remote Desktop (RDP) natively. Essentially this causes you to be required to SSH into Linux VMs, while you remote into Windows VMs over RDP.

How to Setup an Ubuntu Linux VM in Azure with Remote Desktop (RDP) Access 2

If you’re not familiar with Windows Remote Desktop, it’s a technology that lets you remotely connect to a Windows PC or VM from another computer in a manner that enables you to see the screen interface (UI) as if you were sitting directly at that computer.

Traditionally, the only way to remotely connect to a Linux VM is to use SSH (Secure Shell). This is a technology that enables a user to remotely connect to a Linux machine (PC or VM) from another computer using the Shell or command-line interface. Due to the nature of SSH, the Linux machines command-line is only accessible through the SSH connection. You do not get the Desktop-style UI of the Linux machine that you might get if you were to install Ubuntu or some other distribution on a local computer or Virtual Machine (VM).

The xrdp project is an open source project that added Remote Desktop Protocol (RDP) support to Linux machines. By installing xrdp you can add the ability to use Remote Desktop to remote into a Linux VM. This then grants you the ability to connect to the Linux machine with a graphical user interface (UI) similarly to how you would connect to a Windows machine using Remote Desktop.

Setting up a Linux VM in Azure

First, we’ll need to create a Linux VM to use. For this, I’m going to recommend provisioning a Ubuntu Server VM in Microsoft Azure. If you’re unfamiliar with creating a Linux VM in Azure, follow these steps. If you’re already familiar, then feel free to skip down below to the steps to enable RDP support on the Linux VM.

  1. Using the Azure Portal (http://portal.azure.com), click on Create a resource in the left-side navigation, then select the Compute category, then click on Ubuntu Server. At the time of writing this the version listed is Ubuntu Server 16.04 LTS.
    How to Setup an Ubuntu Linux VM in Azure with Remote Desktop (RDP) Access 3
  2. Next, fill in some details about your VM, such as the Name, Username, and method of Authentication. To keep things simple, you’ll want to set the Authentication type to Password, then enter a password you’ll use to login with the User name you’ve entered. Also, don’t forget to specify the Resource Group too, before clicking OK.
    How to Setup an Ubuntu Linux VM in Azure with Remote Desktop (RDP) Access 4
  3. For the VM Size, I would recommend choosing a size with at least 2 vCPUs, as this will give you better performance for the UI. Although, 1 vCPU would work just fine too, just maybe a little more slowly.
    How to Setup an Ubuntu Linux VM in Azure with Remote Desktop (RDP) Access 5
  4. On the Settings pane, you can leave all the default values, and click OK.
  5. Finally, click Create on the Summary pane to create the new Ubuntu Linux VM!
    How to Setup an Ubuntu Linux VM in Azure with Remote Desktop (RDP) Access 6

Now that you have an Ubuntu Server Linux VM, you are ready to setup RDP support.

Installing RDP Support on the Linux VM

To install RDP support on your Linux VM, you’ll need to use SSH to perform the install of xrdp, and you’ll also need to make sure there’s a desktop UI installed on the Linux VM so RDP will work once installed. I recommend using lxde as it’s simple and lightweight.

You can follow these steps to install RDP support and lxde on the Linux VM:

  1. Within the Azure Portal, locate the Virtual machine blade for your Linux VM. Then clicking Create button will give you a sample SSH command to use at the Bash Shell. Or, you can also retrieve the Public IP address from the Overview pane to type the command manually, or using a utility like PuTTy to connect.
    How to Setup an Ubuntu Linux VM in Azure with Remote Desktop (RDP) Access 7The SSH command will have the following syntax:

    ssh <username>@<ip address>
    
  2. When using the SSH command, you’ll need to enter it into a bash shell on your local machine. This could be the “Ubuntu Bash Shell” on Windows 10, or a Terminal window on macOS.
    How to Setup an Ubuntu Linux VM in Azure with Remote Desktop (RDP) Access 8
  3. When prompted, enter the Username and Password what was specified for the Admin user when the Ubuntu Linux VM was created previously.
    How to Setup an Ubuntu Linux VM in Azure with Remote Desktop (RDP) Access 9Also, you’ll likely be prompted with an “Are you sure you want to continue connecting (yes/no)?” message. The reason for this is that your local machine hasn’t seen the key fingerprint from that Linux machine yet. For the sake of the exercise, type yes and press Enter to continue. Once you enter “yes”, you’ll need to enter the SSH command again to initiate the connection.
  4. Next, you’ll need to install a Desktop graphical UI (User Interface) before you’ll be able to setup RDP support. To do this, you can run the following command to install lxde on the Linux VM:
    sudo apt-get install lxde -y

    If you’re interested in using the Ubuntu Desktop UI instead, you can use the great tips from Sorcia25 here: https://sorcia25.wordpress.com/2018/03/02/how-to-setup-an-ubuntu-linux-vm-in-azure-with-remote-desktop-rdp-access-ubuntu-desktop-gui/

  5. Next, you’re ready to install RDP support by installing the xrdp project on the VM. You can do this with the following command:
    sudo apt-get install xrdp -y
  6. Next, you need to start xrdp running on the VM. This can be done with the following command:
    /etc/init.d/xrdp start
  7. Next, before you can Remote Desktop into the Linux VM, you need to be sure to open port 3389 on the Network Security Group (NSG) that is securing access to the VM within Azure. To do this, navigate to the Resource group blade for your VM, then click on the Network Security Group resource.
    How to Setup an Ubuntu Linux VM in Azure with Remote Desktop (RDP) Access 10
  8. On the Network security group blade, click on the Inbound security rules link.
    How to Setup an Ubuntu Linux VM in Azure with Remote Desktop (RDP) Access 11
  9. Click the +Add button then fill in the following details for a new Inbound security rule to open port 3389, then click OK.
    1. Source: Any
    2. Source port ranges: *
    3. Destination: Any
    4. Destination port ranges: 3389
    5. Protocol: TCP
    6. Action: Allow

      How to Setup an Ubuntu Linux VM in Azure with Remote Desktop (RDP) Access 12

With RDP support installed on the Ubuntu Server Linux VM in Azure, and the NSG Firewall is open on Port 3389 to allow RDP connections, you are ready to use a Remote Desktop client to connect.

Connect to Linux VM with Remote Desktop Client

Once RDP support is installed and enabled on a Linux VM, you can now connect to it and remote into the machine using Microsoft Remote Desktop (RDP). You can do this from the Remote Desktop application on Windows, or macOS.

Here’s a screenshot of setting up the connection information using the Microsoft Remote Desktop application on macOS. Note that you need to enter the Public IP Address of the Linux VM in Azure, and the Username and Password that were used to create the VM (or any other username and password that is currently configured on the VM).

How to Setup an Ubuntu Linux VM in Azure with Remote Desktop (RDP) Access 13

And, here’s the final screenshot of what the RDP screen looks like for the Ubuntu Server Linux VM in Azure with both xrdp and lxde installed. This screenshot was taken from macOS using Remote Desktop to connect to the Linux VM running in Azure, and the screen shows the Firefox web browser running on the Linux VM along with a Terminal window running the Bash shell.

How to Setup an Ubuntu Linux VM in Azure with Remote Desktop (RDP) Access 14

I hope this tip and guide help you with your Linux needs in the Microsoft Azure cloud!

Microsoft MVP

Chris Pietschmann is a Microsoft MVP, HashiCorp Ambassador, and Microsoft Certified Trainer (MCT) with 20+ years of experience designing and building Cloud & Enterprise systems. He has worked with companies of all sizes from startups to large enterprises. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.
HashiCorp Ambassador Microsoft Certified Trainer (MCT) Microsoft Certified: Azure Solutions Architect

Discover more from Build5Nines

Subscribe now to keep reading and get access to the full archive.

Continue reading