How to Setup an Ubuntu Linux VM in Azure with Remote Desktop (RDP) Access 2Some 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 3

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 (, 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 4
  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 5
  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 6
  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 7

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 8The 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 9
  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 10Also, 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:

  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 11
  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 12
  9. CHow to Setup an Ubuntu Linux VM in Azure with Remote Desktop (RDP) Access 13lick 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

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 14

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 15

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


Subscribe to the Build Azure Weekly newsletter to receive similar updates about Microsoft Azure and related topics!

We respect your privacy and take protecting it seriously. We do not sell our email list, and you can unsubscribe at any time.

Posted by Chris Pietschmann

Chris is a Microsoft MVP and has nearly 20 years of experience building enterprise systems both in the cloud and on-premises. He is also a Microsoft Certified Azure Solutions Architect and developer, a Microsoft Certified Trainer (MCT), and Cloud Advocate. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.


  1. Nice guide. Thank you sharing this.


  2. […] days ago Chris Pietschmann wrote about How to Setup an Ubuntu Linux VM in Azure with Remote Desktop (RDP) Access (great job certainly), and in a little ping pong messages I ask about how to enable another […]


  3. Nice one Chris.
    Looks like this doesn’t work with Remote Desktop Connection Manager and RDP session should be launched separately to be able to see something else than a blank screen.


    1. Chris Pietschmann March 7, 2018 at 4:53 pm

      I’ve connected to a Linux VM with xrdp like the article describes from both Windows and Linux desktop computers. I’m not sure what the issue is that you’re seeing. If you find more information about this, please share, and maybe we can figure it out. 🙂


      1. I also followed all the steps, and in the end when I connect to the remote VM all I see is a black blank screen

      2. Chris Pietschmann April 22, 2018 at 9:20 pm

        Are you sure there weren’t any errors when you ran the necessary commands to set things up?

  4. Nice, thanks for the write up.
    To use xfce4 instead of lxde I found I also had create an .xsession file in the user home directory:
    echo xfce4-session >~/.xsession


  5. Melwin Dmello May 18, 2018 at 7:32 am

    Thanks for this post. It helped me!! I just faced an issue with xrdp running on 3389.

    (Writing this, in case it helps someone else)

    I setup an Ubuntu 18.04 LTS on Azure. For some reason enabling port 3389 using Network Security group didn’t work for me.
    Therefore, I used the Endpoints options to expose port 3389.

    Also, after executing /etc/init.d/xrdp start, check the status using sudo service xrdp status
    In my case, there were some issues :
    May 18 10:55:22 ubuntuMachine1 xrdp[36242]: (36242)(140648438613824)[ERROR] Cannot read private key file /etc/xrdp/key.pem: Permission denied

    I resolved this by:
    sudo chmod 777 /etc/xrdp/key.pem
    sudo service xrdp stop
    sudo service xrdp start
    (Probably, running xrdp with sudo would have worked!!)

    Checking status again, showed:
    May 18 10:58:38 ubuntuMachine1 xrdp[36655]: (36655)(140482085226304)[INFO ] listening to port 3389 on

    Once, xrdp was listening on 3389. I could RDC from my windows machine and I connect my Ubuntu VM ‘s deskop!!!
    Thanks again Chris!! Cheers!


  6. Thanks for the tips. So far I haven’t used Azure yet for setting up Linux VMs; just Virtualbox. Great article.


  7. umutalparslan June 26, 2018 at 3:59 am


    I setup the Linux VM but not working. Please help me. My Inbound Port Rules -> and RDP Error -> VM work right now but RDP not connecting.


    1. Chris Pietschmann June 30, 2018 at 1:59 pm

      Did you follow the steps outlined in the article? Perhaps retrace and double check.


      1. umutalparslan June 30, 2018 at 6:13 pm

        Yes, I follow to step by step but not working

      2. Chris Pietschmann June 30, 2018 at 7:37 pm

        Something may have gone wrong. Did you try it again with a new VM?

  8. the instructions were clear and succinct, worked like a charm!


  9. Superb Chris… You saved my day… I just did what was told here and walla… my linux VM was up and running in Azure…


  10. I followed the instructions after having deployed a fresh Microsoft Ubuntu VM (linux-data-science-vm-ubu).

    I can get through the login screen okay and can see on log as last message that ‘connection complete, connected ok’, but then I get gray screen, apparently waiting for some content to appear, I see a cursor as X..

    But then the window dies and disappears in 1-2 seconds..Both using Windows 7 and Windows 10 as client machines…



    1. Chris Pietschmann October 16, 2018 at 10:58 am

      The Ubuntu machine may not be setup correctly. Also, I’ve seen this type of issue if the Desktop UI, if not using lxde, may not be compatible with xrdp.


      1. Right.. I am sure you are right.. 😉

        Fortunately I was able to skip debugging phase as I found out that the Azure system was pre-configured with X2go so I got this running simply installing and configuring the client on my Windows machines

      2. I tried this, xrdp got running nice and easy but connecting just gave issues after the login screen, from both windows and macOS.
        The Azure data science ubuntu box comes with x2Go server installed and running out of the box.
        Just download the x2go client and you get up and running instantly.

        I have to say that x2go experience is far nicer way to RDP into linux!

  11. Awesome post Chris. I was well into it following the instructions when I saw your “username” in the settings and realized this was yours! On the “One Year Anniversary” of the post, I thought I’d give you an update or two. 🙂 As you are aware, Azure changes regularly, so now you can just select the Ports 22 and 3389 during the build in the allow ports section, no need to build or modify any NSG. You can, if you miss that during the build and only select 22, but this is at least capable of being done in one step during the deploy if you would like.

    Hope things are going well my friend!


    1. Chris Pietschmann March 3, 2019 at 7:12 pm

      Thanks! And, thanks for pointing this out. Everything is great, I hope you are well too. 🙂


  12. Wilfredo Sanchez H. March 21, 2019 at 4:24 pm

    Thanks for it.


  13. Keyboard does not work!


    Thanks for this article. I am using an iPad with an external keyboard.
    The VM starts fine, but once the Desktop loads, no keyworks, only mouse works.


    1. Chris Pietschmann July 2, 2019 at 4:36 pm

      You’re having an iPad related issue. Keyboard input to the VM works just as expected to the Linux VM over RDP as it would with Windows.


Leave a Reply

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