Enable graphical remote desktop for Linux virtual machines in Azure Lab Services

This article shows you how to do the following tasks:

  • Enable graphical remote desktop sessions for a Linux VM
  • How to connect to a Linux VM using RDP (Remote Desktop Protocol) or X2Go remote desktop clients

Set up graphical remote desktop solution

When a lab is created from a Linux image, SSH (Secure Shell) access is automatically configured so that the instructor can connect to the template VM from the command line using SSH. Likewise, when the template VM is published, students can also connect to their VMs using SSH.

To connect to a Linux VM using a GUI (graphical user interface), we recommend using either RDP or X2Go. The rest of this article shows the steps to set up RDP or X2Go on a lab's template VM.

Note

Linux uses an open-source version of RDP called, Xrdp. For simplicity, we use the term RDP throughout this article.

RDP Setup

To use RDP, the instructor must:

  • Enable remote desktop connection; this is specifically needed to open the VM's port for RDP.
  • Install the RDP remote desktop server.
  • Install a Linux graphical desktop environment.

X2Go Setup

To use X2Go, the instructor must:

  • Install the X2Go remote desktop server.
  • Install a Linux graphical desktop environment.

X2Go uses the same port that is already enabled for SSH. As a result, no extra configuration required to open a port on the VM for X2Go.

Note

In some cases, such as with Ubuntu LTS 18.04, X2Go provides better performance. If you use RDP and notice latency when interacting with the graphical desktop environment, consider trying X2Go since it may improve performance.

Important

Some marketplace images already have a graphical desktop environment and remote desktop server installed. For example, the Data Science Virtual Machine for Linux (Ubuntu) already has XFCE and X2Go Server installed and configured to accept client connections.

Enable remote desktop connection for RDP

This step is only needed to connect using RDP. If instead you plan to use X2Go, you can skip to the next section since X2Go uses the SSH port.

  1. During lab creation, the instructor has the option to Enable Remote Desktop Connection. The instructor must enable this option to open the port on the Linux VM that is needed for an RDP remote desktop session. Otherwise, if this option is left disabled, only the port for SSH is opened.

    Screenshot that shows the "New lab" window with the "Enable Remote Desktop Connection" option.

  2. On the Enabling Remote Desktop Connection message box, select Continue with Remote Desktop.

    Enable remote desktop connection for a Linux image

Install RDP or X2Go

After the lab is created, the instructor needs to ensure that a graphical desktop environment and remote desktop server are installed on the template VM. The instructor must first connect to the template VM using SSH to install the packages for:

  • Either the RDP or X2Go remote desktop server.
  • A graphical desktop environment, such as GNOME, MATE, XFCE, Xubuntu, etc.

After this is set up, the instructor can connect to the template VM using either the Microsoft Remote Desktop (RDP) client or X2Go client.

Follow the below steps to set up the template VM:

  1. If you see Customize template on the toolbar, select it. Then, select Continue on the Customize template dialog box. This action starts the template VM.

    Customize template

  2. After the template VM is started, you can select Connect template and then Connect via SSH on the toolbar.

    Connect to template via RDP after the lab is created

  3. You see the following Connect to your virtual machine dialog box. Select the Copy button next to the text box to copy it to the clipboard. Save the SSH connection information. Use this connection information from an SSH terminal (like Putty) to connect to the virtual machine.

    SSH connection string

  4. Finally, install either RDP or X2Go along with the graphical desktop environment of your choice.

For optimal performance, we typically recommend using the XFCE graphical desktop and for users to connect to the desktop using X2Go. To set up XFCE with X2Go on Ubuntu, use the following instructions: - Install and configure X2Go

In cases where you instead need to have users connect to the graphical desktop with RDP, use the following instructions for Ubuntu: - Install and configure RDP

Using GNOME or MATE graphical desktops

For the GNOME or MATE graphical desktop environments, you may encounter a networking conflict with the Azure Linux Agent which is needed for the VMs to work properly in Azure Lab Services. This networking conflict causes the following side effects when Ubuntu 18.04 LTS is used with either GNOME or MATE installed:

  • Lab creation using the image will fail with the error message, Communication could not be established with the VM agent. Please verify that the VM agent is enabled and functioning.
  • Publishing student VMs will stop responding if the auto-shutdown settings are enabled.
  • Resetting the student VM password will stop responding.

We recommend using the following instructions to set up the GNOME or MATE graphical desktops on Ubuntu. These instructions include a fix for the networking conflict that exists with Ubuntu 18.04 LTS. They also support installing GNOME and MATE on Ubuntu 20.04 LTS and 21.04 LTS:

Connect to the template VM via the GUI

After the template VM is set up, the instructor can connect via the GUI using either the Microsoft Remote Desktop (RDP) client or X2Go client. The client that you use depends on if RDP or X2Go is configured as the remote desktop server on the template VM.

Microsoft Remote Desktop (RDP) client

The Microsoft Remote Desktop (RDP) client is used to connect to a template VM that has RDP configured. The Remote Desktop client can be used on Windows, Chromebooks, Macs and more. Refer to the article on Remote Desktop clients for further details.

Follow the below steps based on the type of computer used to connect to the template VM:

  • Windows

    1. Click Connect to template on your lab's toolbar and select Connect via RDP to connect to the template VM.
    2. Save the RDP file and use it to connect to the template VM using the Remote Desktop client.
    3. Typically, the Remote Desktop client is already installed and configured on Windows. As a result, all you need to do is click on the RDP file to open it and start the remote session.
  • Mac

    1. Click Connect to template on your lab's toolbar and then select Connect via RDP to save the RDP file.
    2. Then, refer to the how-to article Connect to a VM using RDP on a Mac.
  • Chromebook

    1. Click Connect to template on your lab's toolbar and then select Connect via RDP to save the RDP file.
    2. Then, refer to the how-to article Connect to a VM using RDP on a Chromebook.

X2Go client

The X2Go client is used to connect to a template VM that has X2Go configured. Using the template VM's SSH connection information, follow the steps in the how-to article Connect to a VM using X2Go.

Next steps

After an instructor sets up either RDP or X2Go on their template VM and publishes, students can connect to their VMs via the GUI remote desktop or SSH.

For more information, see: