Enabling Remote Desktop Access with xrdp on a Raspberry Pi

If you need to run your Raspberry Pi “headless” (without a monitor) you can connect to it via SSH. But if you need access to the desktop then one option is to use VNC, which is great if you aren’t already using Microsoft’s Remote Desktop Protocol (RDP) to connect with other servers. But if you are already using RDP then it is more convenient to enable RDP access to the Raspberry Pi and stick with just one type of client viewer.

RDP is a proprietary protocol developed by Microsoft. It is used primarily in Microsoft’s Windows Server products so that the servers can run without a monitor attached. All modern desktop versions of Windows (like Windows Vista, Windows 7 and Windows 8) all come with an RDP viewer (called Remote Desktop Connection) pre-installed. This means you won’t need to install any extra software to access the Pi’s full desktop from a Windows PC.

There are several different implementations of the RDP protocol for Linux including xrdp. The xrdp project the remote desktop protocol to provide access to a Linux desktop not a Windows desktop. The xrdp server is able to work with other open source RDP clients as well as with Microsoft’s Remote Desktop Connection program.

To install xrdp on a Raspberry Pi running Raspbian use:

sudo apt-get install xrdp

xrdp will be installed as a service and will be started automatically. There is no further configuration needed to make a remote connection. On a Windows PC, launch the Remote Desktop Connection program. In the “Computer:” field, enter the IP address of your Pi. The How to Use a Static IP Address and Setup SSH on a Raspberry Pi tutorial has more information about configuring IP addresses. If you have Samba installed then you can just use the Windows networking name for your device. The default is raspberrypi. Now click connect.

xrdp-login

The xrdp login screen will appear in a new window. Here you can enter the username and password of any user on your Raspberry Pi. If you are using the default configuration then enter pi and raspberry and click OK.

xrdp-set-resolution-in-rdc

The default screen resolution isn’t set on the Raspberry Pi but rather from the client. When the Remote Desktop Connection program contacts the Pi part of the initial protocol, negotiation is to establish the screen resolution and other things like the color depth. To change the screen resolution, click on “Show Options” to reveal the advanced connection settings. Under the Display tab, use the slider to choose the size of the remote desktop. Drag the slider all the way to the right to use full screen mode.

As we have seen, the xrdp server doesn’t require configuration and works out-of-the-box, however there are a few things that can be tweaked. The xrdp.ini configuration file resides in /etc/xrdp and contains a few variables that can be set. To edit the file type:

sudo nano /etc/xrdp/xrdp.ini

The file is divided into different sections, each marked by a name in square brackets. In the [globals] section you can disable compression by setting the bitmap_compression variable to no. This may improve performance as it removes the need for the Pi to perform certain compression tasks which can be CPU intensive. You will likely only see a performance improvement on a very busy Pi.

The Remote Desktop Protocol has three encryption levels: low, medium and high. Low is 40 bit encryption and data is only encrypted from the client to the server. Medium is 40 bit encryption but data is encrypted in both directions. High is 128 bit encryption and like the Medium level is in both directions. To change the security level, modify the crypt_level variable.

In the [xrdp1] section, it is possible to set a default username and password which means that they don’t need to be entered into the xrdp login dialog. If you want to limit access to your Pi then don’t change these variables, though for convenience sake, you may want to change the username to your default user, however note that you can’t enter a different username if you want to login as someone else.

The xrdp server provides an easy way to access your Pi from a Windows PC and the ability to define the screen resolution when you connect is a distinct advantage, Ironically xrdp actually uses the TightVNC server to manage the X session, so if you don’t have a special preference for RDP then you could just use VNC.