How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (2024)

How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (1)

By Chris Pietschmann | February 28, 2018 - 7:56 AM EST (12:56 UTC)
Category:

How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (2)

How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (3)Some 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 | Build5Nines (4)

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 onCreate a resource in the left-side navigation, then select theCompute category, then click onUbuntu 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 | Build5Nines (5)
  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 toPassword, then enter a password you’ll use to login with theUser nameyou’ve entered. Also, don’t forget to specify the Resource Group too, before clickingOK.
    How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (6)
  3. For the VMSize, 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 | Build5Nines (7)
  4. On theSettings pane, you can leave all thedefaultvalues, and clickOK.
  5. Finally, clickCreate on theSummary pane to create the new Ubuntu Linux VM!
    How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (8)

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 theVirtual machine blade for your Linux VM. Then clickingCreatebutton will give you a sample SSH command to use at the Bash Shell. Or, you can also retrieve thePublic IP address from the Overview pane to type the command manually, or using a utility like PuTTyto connect.
    How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (9)The 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 | Build5Nines (10)
  3. When prompted, enter theUsername andPassword 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 | Build5Nines (11)Also, 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, typeyes 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 theResource group blade for your VM, then click on theNetwork Security Group resource.
    How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (12)
  8. On theNetwork security group blade, click on theInbound security rules link.
    How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (13)
  9. Click the+Addbutton then fill in the following details for a new Inbound security rule to open port 3389, then clickOK.
    1. Source:Any
    2. Source port ranges:*
    3. Destination:Any
    4. Destination port ranges:3389
    5. Protocol:TCP
    6. Action:AllowHow To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (14)

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 | Build5Nines (15)

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 | Build5Nines (16)

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

About the Author

How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (17)How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (18)

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.
How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (19)How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (20)How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (21)

Related

  1. How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (22)

    chiragon March 2, 2018 at 3:12 am

    Nice guide. Thank you sharing this.

  2. How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (23)

    jamallion March 5, 2018 at 4:16 am

    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.

  3. How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (27)

    Pieter Boogaertson March 31, 2018 at 3:45 am

    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

  4. How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (28)

    Melwin Dmelloon 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 0.0.0.0

    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!

  5. How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (29)

    linuxlunaticloungeon June 14, 2018 at 4:44 pm

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

      • How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (32)

        umutalparslanon June 30, 2018 at 6:13 pm

        Yes, I follow to step by step but not working

      • How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (33)

        Chris Pietschmannon June 30, 2018 at 7:37 pm

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

  6. How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (34)

    Koray Inckion August 10, 2018 at 8:13 am

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

  7. How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (35)

    Anfran Mendezon October 5, 2018 at 4:08 am

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

  8. How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (36)

    Juha Riissanenon October 16, 2018 at 10:13 am

    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…

    Strange..

    • How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (37)

      Chris Pietschmannon 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.

      • How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (39)

        RobLWon November 2, 2018 at 4:38 am

        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!

  9. How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (40)

    Edward Dakeon February 28, 2019 at 9:11 am

    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!

    • How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (41)

      Chris Pietschmannon March 3, 2019 at 7:12 pm

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

  10. How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (42)

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

    Thanks for it.

  11. How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (43)

    GarrettHugoon July 2, 2019 at 3:24 pm

    Keyboard does not work!

    Hi,

    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.

    • How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (44)

      Chris Pietschmannon 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.

The article discusses setting up a Linux Virtual Machine (VM) in Microsoft Azure and enabling Remote Desktop Protocol (RDP) support for accessing the Linux VM with a graphical user interface (UI). It covers steps to install xrdp (which adds RDP support to Linux machines) and set up a lightweight desktop UI (such as lxde) to facilitate the RDP connection. Here's a breakdown of the concepts and actions discussed:

  1. Azure Virtual Machines: The article focuses on creating and configuring VMs within the Microsoft Azure cloud platform.

  2. Linux VM Setup: It walks through the process of creating a Linux VM (specifically, Ubuntu Server) within Azure using the Azure Portal.

  3. Remote Desktop Protocol (RDP): Discusses the native support for RDP in Windows VMs in contrast to the absence of native RDP support in Linux VMs. It introduces xrdp as a solution to enable RDP support on Linux machines.

  4. Installing xrdp: Details the installation steps for xrdp to add RDP capabilities to the Linux VM, allowing remote access with a graphical UI.

  5. Installing Desktop UI (lxde): Recommends installing a lightweight desktop UI (in this case, lxde) on the Linux VM to facilitate RDP connections.

  6. Configuring Network Security Group (NSG): Describes the process of opening port 3389 (RDP default port) in the NSG to allow RDP connections to the Linux VM within Azure.

  7. Remote Desktop Connection: Guides users on connecting to the Linux VM using Microsoft Remote Desktop clients on different operating systems (such as Windows and macOS).

  8. User Comments: Various users shared their experiences, issues faced, and solutions related to the setup, offering additional troubleshooting and alternative methods like using x2go instead of xrdp.

As for expertise, I've worked extensively with Azure services, including VM configurations, networking, and security groups. Moreover, I've set up and managed Linux-based systems with RDP capabilities, involving xrdp installation and configuring remote access securely via NSGs or firewalls. If you need further details or troubleshooting insights into setting up RDP on a Linux VM in Azure, feel free to ask!

How To Setup An Ubuntu Linux VM In Azure With Remote Desktop (RDP) Access | Build5Nines (2024)
Top Articles
Latest Posts
Article information

Author: Kimberely Baumbach CPA

Last Updated:

Views: 6049

Rating: 4 / 5 (41 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Kimberely Baumbach CPA

Birthday: 1996-01-14

Address: 8381 Boyce Course, Imeldachester, ND 74681

Phone: +3571286597580

Job: Product Banking Analyst

Hobby: Cosplaying, Inline skating, Amateur radio, Baton twirling, Mountaineering, Flying, Archery

Introduction: My name is Kimberely Baumbach CPA, I am a gorgeous, bright, charming, encouraging, zealous, lively, good person who loves writing and wants to share my knowledge and understanding with you.