Remote Desktop to Ubuntu in Windows Azure

When it comes to Microsoft, people don’t generally think “Open Source” or “Linux Support”. But in recent years, Microsoft has come a long way. They’ve released many of their most commonly used frameworks under open source licenses, including ASP.NET MVC/Web API/Web Pages and Entity Framework!

Additionally, they’ve given first-class support for many non-Microsoft offerings, especially in Azure. Currently, this includes support in Azure for open source gems like Node.js, PHP, and, yes, even Linux. Heck, they even have an Openness logo:

In this post, I’ll walk you through setting up the Ubuntu Desktop on an Azure Virtual Machine and configure it so you can connect to it through Windows Remote Desktop. It’s a lot easier than you think!

WARNING: Heavy usage of RDP over Azure could result in lots of out-going bandwidth usage, which could mean a very large bill for your Azure account. Be careful and make sure you check your bandwidth usage!

Part One: Creating The Virtual Machine

Creating a Virtual Machine in Azure is surprisingly simple. You will need an Azure account (sign up for the Free Preview if you don’t have one). Then, you’ll use the “Preview” portal at

As of this writing, you can create a Virtual Machine in Azure preinstalled with four different flavors of Linux (OpenLogic CentOS 6.2, SUSE Linux Enterprise Server, Ubuntu Server 12.04 LTS and openSUSE 12.1), or upload your own custom VHD. We’ll just use the easy way.

To get started, click “Virtual Machines” on the left side, then select “New” on the bottom bar, followed by “Virtual Machine” and “From Gallery”.

This brings up the “VM OS Selection” dialog. Choose “Ubuntu Server 12.04 LTS” to continue.

On the next page, name your machine. Note that this is the machine’s internal host name, not the external DNS name, though I tend to use the same name for both to avoid confusion. I called my machine “tommck-desktop”.

You also will enter a username/password combo and a size of the machine instance. I chose a “Medium” instance (dual core, 3.5GB RAM) since the Desktop takes quite a bit more memory than a server installation. A “Small” instance will work fine, but the installation may just take a bit more time. Check out this link for more information on the instance size specs.

Next, you choose the third-level DNS name for your instance. Note: for this purpose, we’re using a “Standalone” machine, since we’re not creating a “server farm.”

“Availability Sets” are also something used for “server farms.” We’ll just leave this as “(None)” and click the check mark (√) to finish.

Once that is done, you will see the “Virtual Machines” page with your new VM in the “Starting (Provisioning)” state. It should take a total of approximately five minutes for the machine to fully provision.

I may be easily impressed, but getting a fully installed Linux VM running in under five minutes is pretty darn cool in my book. Now it’s time to set the rest up.

Part Two: Initial Ubuntu Configuration

A word of caution: this is a PREVIEW! There are definitely a few kinks when working with the Linux VMs, but I’m sure Microsoft is working to fix them. If you run into any problems, consult the “Troubleshooting” section at the end of this post.


You’ll need an SSH client to connect to your Ubuntu VM. Some options for Windows are:

  • Cygwin (my preference, way more than just SSH and command-line based)
  • Putty (a very popular option)
Now, connect to the server’s full DNS name “[servername]” with ssh and login with the username you specified during setup.

Bug workaround – IMPORTANT! There seems to be some sort of problem with either Ubuntu, or Azure’s integration with it. The problem manifests after some software updates on the machine (most likely one in particular, but I’m not sure which one). The end result is that you lose your right to run “sudo,” thus removing all ability to access the machine as an administrator.

The only way I know that gets around this is to set a password for “root” (DO THIS NOW):

$ sudo passwd root

This will allow you to set up a password for the true “superuser” on the box, which is not enabled by default. Thus, when problems running sudo occur, you can login as the “root” user and continue. The good news is that the problem goes away after a reboot if you also run:

$ sudo usermod –G admin [username]

This puts your username in the “admin” group in order to make sure you continue to have sudo access after restarting. You will still have problems after the first update.

If, at any time, the system tells you that “username is not in the list of ‘sudoers,’” just use “su –“ and enter the root user’s password to proceed. This will not be necessary after a reboot.

Hopefully this will be fixed by the time you read this so you don’t experience this problem.

Part Three: Installing Desktop and Remote Support (xrdp)

The Desktop

To use a Remote Desktop, we actually need to have a Desktop. So, we’ll install the standard Ubuntu Desktop followed by “xrdp”, which implements the RDP protocol with VNC server software as its backing. This is quite simple to do (just answer yes to any prompts):

$ sudo apt-get install ubuntu-desktop 
$ sudo apt-get install xrdp

That’s it!

Accessing the Desktop Remotely

The simplest approach for allowing RDP access is to add an Endpoint to your Virtual Machine from the Portal. To do this, first click “Endpoints” at the top, then “Add Endpoint” on the bottom. Once there, add the Endpoint named “RDP” using TCP protocol and port 3389 (both public and private)

Once that’s done updating, you can go back to the VM screen and click “Connect” on the bottom of your screen:

This will download a “.rdp” file which will connect you to your VM.

You will be presented with a slightly unusual-looking login screen like this:

Note that you’ll need to change the “username” to your user and enter your password. Once that’s done, you’ll get an Ubuntu Desktop!

I’m sure you’ll notice that it’s not very fast. I highly recommend you use the Remote Desktop client’s Display options to select lower color depth (16-bit or lower) and as small a resolution as you feel comfortable with. This will speed things up considerably.

Part Four: Lock It Down!

For security purposes, most people won’t expose RDP directly to the internet. For this reason, I would strongly recommend using an SSH tunnel to connect your Remote Desktop connection. This way, all the traffic is encrypted locally and decrypted on the server, preventing any interception of the data being transmitted.

First, delete the Endpoint you previously made to enable RDP connectivity then. Next, pick a port greater than 1023 (I chose 5999) to use locally. Now, set up a “tunnel” from your local machine using ssh that proxies local port 5999 to remote port 3389 (the RDP port) like this:

$ ssh –NL 5999:localhost:3389

Now, assuming there are no errors, start Remote Desktop and connect to “localhost:5999”. This should work just like last time, just much more securely.

Part Five: Troubleshooting

ssh timeouts

I occasionally receive this painful error with ssh:

Unfortunately, they don’t go away easily. The first thing to try is to use the Portal itself to restart the VM. If that doesn’t work, things get a bit hairy from there. Most solutions include deleting the VM (it won’t delete your disk) and then setting up the VM again pointing to the same disk. This is definitely ugly and will hopefully be resolved soon. Contacting Microsoft for help at this point would be highly recommended.

SUDO problems (username is not in the list of ‘sudoers’)

If you run into this problem, use “su –“ and type the root password. You should then have a “#” prompt and be running as “root”. Perform whatever superuser functions you need here, and reboot, which should fix the problems with sudo. If you did not follow the “sudo passwd root” step above, you are pretty much stuck. If you need to get to the disk, you’ll need to mount it within another VM in order to access it and modify it.

I’m not on Windows!

There are Remote Desktop clients for non-Windows Operating Systems. If you prefer not to go that route, you can skip using xrdp and just use VNC directly. There are clients for most every operating system you can imagine. Feel free to ask if you need assistance with alternate connection options.

About Tom McKearney

Thomas has been with AIS for almost 12 years. His background has been varied and has been involved in nearly all mission critical development areas, including Automated Weather Observation, Phone Switch Management, Financial Software, Facial Recognition, Fingerprints, Document Management Systems and Military Battle Simulation Software, etc.
He has developed at all levels, from on-chip Smart Card development and Embedded systems up to large scale distributed systems deployed to Azure. The last 12 years he has been almost exclusively doing .NET development in C#. He recently lead a multi-year Azure-based project for a large commercial jewelry store chain, followed by an effort on a Windows 8.1 tablet based application in WinJS. Some of his specialties are: Software Architecture (Analysis, Design and Implementation), general problem solving, various .Net-related toolsets like Azure, WPF, Silverlight, JavaScript, HTML and related web technologies.

He is also technical reviewer on various books, including Windows Store App Development (C# and XAML), Windows 8 Phone in Action, Silverlight 5 in Action, Silverlight 4 in Action and Scratch 1.4 Beginner’s Guide.

  • Thanks a lot helped me 🙂
    simple procedure..:)

  • once again thanks 🙂

  • Borrierulez


  • Majid

    Thank you very much for your complete and great explanation 🙂 

  • Aadarsh_bohara

    It helps like anything…how can I enable ftp ??

    • You should be able to open up the FTP port in the same way. I believe FTP is hosted on port 21, but it uses other ports during typical usage, so it’s more difficult to set up. There are some articles out there on setting up “Passive mode” FTP in Windows, but it points to restrictions on the number of Firewall ports being a limiting factor.

      If you can, you should just use “scp”, which will copy files over the SSH link.  This way, you don’t need to open up any additional ports.

      If you’re stuck with FTP, you may also take a look at doing FTP _over_ SSH, which is possible as well.

      Hope that helps.


  • Pingback: Challenge 1: Building a HTML5 CSS3 Website on Ubuntu under Windows Azure | yvivas440()

  • Azdous

    Worked as described. Thanks

  • Sanjay

    Thanks a lot, this helped me login to the Ubuntu server image on Azure. But after I restarted the server, I am not able to remote login again. It says that the Remote server is either not on network or switched off or remote desktop is not enabled.

    • Is your RDP port open? Look for port 3389 in your firewall settings on the portal.  Are you able to login with SSH?

  • Levkad

    I tried to follow your steps and it worked well beside the last step
    I can’t see the icons on the left side and can’t run any shell
    just putty from my local pc works

    please help 🙂

  • r0bt

    I followed the steps but Ubuntu says that Compiz crashed. Also, when I run command line via ssh, it says that Compiz can’t open the display.

    • I get the same thing. Glad I’m not alone… wish there was a fix though.
      I got an update the first time I logged in and ran it. Maybe I shouldn’t have? I don’t want to start from scratch again but I might have to.

      • Tom McKearney

        Sorry it took so long to be able to research this.
        I am guessing you are using Ubuntu version > 12.04. Starting in 12.10, the Unity desktop (the default for Ubuntu) switched to 3D graphics only (driven by compiz). Xrdp does NOT support any 3D desktop, so you must either go back to 12.04, or use an alternate desktop
        I will update the post here, or create a new post to describe this and show you how to use a different desktop.

  • lol

    Where do you put DNS name into Putty?

  • Maxfridbe

    Could you make one for the latest ubuntu. It seems to have issues doing these steps.

    • Tom McKearney

      I will update this to include a way to make it work, but you won’t be able to use the default Unity desktop because it requires 3D graphics and Xrdp doesn’t support it.

  • Pingback: KenterOnline | Remote Desktop to Ubuntu in Windows Azure | Applied Information Sciences Blog()

  • Nishant

    I am trying to achieve this with Ubuntu 13.04 but once I get .rdp file to remotely connect to Ubunut GUI, It is getting stuck on the orange screen. It is not going in.

    • Tom McKearney

      you must change to an alternate, non-3D desktop (Unity is all 3D now) in order to work with Xrdp. Update to this post coming soon

    • Agustin Silva

      in order to make it work with Ubuntu 13.04 you will need to install an alternate desktop. this is what I did:
      sudo apt-get install xfce4

      then modified the .xsession file in your home directory (if you dont have one, create it) and put the following line:


      Save the file and restart the xrdp service with the following command:

      sudo service xrdp restart

      That’s it. I should work right now.

  • FrankP

    This video on YouTube: showed good instructions for getting the 2D desktop setup and working

  • Eunix Caitlynn Alberto


  • Pingback: Azure – Remote desktop from Windows to an OpenSUSE Linux | Developers Questions -

  • first step is sudo apt-get update

  • azureuser1

    Thanks for the tutorial. Everything worked but the desktop did not startup.
    I just get a terminal window.
    Any clues?

  • Aparna

    I followed all the steps mentioned in this article. (It is a great piece 🙂 )
    But once i login, i just get a blank screen. Nothing happens whichever key i press.
    Any pointers to this?

  • madan

    very helpfull.
    Where can i find the setting for
    @ Remote Desktop client’s Display options to select lower color depth
    do i need to do it on ubuntu vm or on my machine.

  • Omer

    Pay attention that you need to user ubuntu 12.04 and not 14.

  • Michael Keighery

    This was very useful, thanks!

  • Pingback: How To Put Icons On Desktop Ubuntu 12.10 | Information()