Remote Desktop to your Linux Azure Virtual Machine

If you’ve ever wished you could get a GUI experience with your Azure Linux VM’s, here’s how you can do it. While I’m not suggesting you should do this for production VM’s that are running server workloads, there are times when it could be useful to get a full GUI with Linux. If you are onboard, here’s what you need to do.

Note: If you want you could just follow the steps for getting VNC installed and be done. However, being able to use an RDP client from any Windows machine without installing anything could be more convenient.

I used CentOS 7.1 from the Azure gallery but other RedHat based Linux distros will probably work (e.g. Oracle Linux)

1) Login to your Linux VM

2) Install the GNOME Desktop using this command:

sudo yum groupinstall "GNOME Desktop" "Graphical Administration Tools".

This will take several minutes

3) Install TigerVNC:

sudo yum install tigervnc-server xorg-x11-fonts-Type1

4) Copy the vncserver.service file:

sudo cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service

5) Using something like vi, edit /etc/systemd/system/vncserver@:1.service. Look for the <USER> tags in the file and replace with your Linux username.

# Clean any existing files in /tmp/.X11-unix environment

ExecStartPre=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’

ExecStart=/sbin/runuser -l <USER> -c “/usr/bin/vncserver %i”


ExecStop=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'[Install]

6) If you are running a firewall, you may need to open the ports we will need:

firewall-cmd –permanent –zone=public –add-port=5901/tcp
firewall-cmd –permanent –zone=public –add-port=3389/tcp
firewall-cmd –reload

7) Install XRDP using these commands:

sudo rpm -Uvh
rpm -Uvh
sudo yum install xrdp
sudo chcon -t bin_t /usr/sbin/xrdp*
sudo systemctl start xrdp.service
sudo systemctl enable xrdp.service
sudo systemctl start xrdp-sesman.service

8) Start VNCServer

You will get prompted to enter a VNC password

9) Verify that VNCSever and XRDP are running with netstat –ant:


10) Next add the endpoints for RDP and VNC to your Linux VM. It’s probably a good idea to use ACLs to restrict access from a particular remote subnet (see this: Go to your Linux VM in the Azure Management Portal and click on EndPoints. Add an Endpoint for RDP and VNC on ports 3389 and 5901. I picked a random port for RDP (you could do the same for VNC):



11) At this point you can test connectivity using a VNC Viewer:




12) Next, try a Remote Desktop Connection:





12) (optional) If you don’t need VNC exposed externally, you can delete the Azure endpoint and just use RDP

Comments (3)

  1. Mitesh Jain says:

    Good steps Pete. It helped me set up a Linux VM.


    Once the VM reboots it wont directly connect using VNC. I ned to give the command vnserver each time the server reboots and then I am able to connect using vnc.

    Is there a way that vncserver is automatically started if the server reboots?

  2. Thanks Mitesh! This article might help you:…/how-do-i-start-vnc-server-on-boot. The first answer in that thread should be the one. Let me know how it goes.

  3. Andrew says:

    Very clear instructions, thanks for the info. However, I’m still having trouble with my VM created with the Resource Manager deployment model. The instructions above talk about adding an endpoint, but since I’m using the Resource Manager deployment model, there’s no settings or menu items where I can create one. Instead I added inbound rules to my network security group to allow traffic to ports used by xrdp and vncserver. Rdp and VNC viewer both timeout when I attempt to connect.

    Additionally, I used the sudo netstat -ant command to confirm that both ports (for xrdp and vncserver) are both in the “LISTEN” state. What am I missing here?

    Thanks for your time.

Skip to main content