Xrdp is an open-source equivalent of Microsoft’s Remote Desktop Protocol (RDP). With xrdp installed on a Linux system, users can remotely access the Linux desktop using an RDP client as we shall demonstrate later in this article. It’s completely free to download and use.
Without much further ado, let’s see how you can install Xrdp on Ubuntu Desktop 20.04 and 18.04.
This guide assumes that you already have a copy of the Ubuntu 20.04 or Ubuntu 18.04 desktop already installed. If you have a minimal installation – without a GUI – then installing a desktop environment (such as GNOME) is recommended.
To install the Ubuntu desktop environment, run the command:
$ sudo apt install ubuntu-desktop
Step 1: Install Xrdp on Ubuntu 20.04
To start off, launch your terminal and invoke the following command to install Xrdp on your system.
$ sudo apt install xrdp
When prompted, just hit
'Y' and press enter to continue with the installation.
Xrdp service starts automatically upon installation. You can verify this by running the command:
$ sudo systemctl status xrdp
The output confirms, without a doubt, that the xrdp daemon is active and running.
Step 2: Configure Xrdp on Ubuntu 20.04
When Xrdp is installed, an SSL certificate key – ssl-cert-snakeoil.key – is placed in the /etc/ssl/private/ folder. We need to add the xrdp user to the ssl-cert group to make the file readable to the user.
$ sudo adduser xrdp ssl-cert
Xrdp listens on port 3389 and if you are behind a UFW firewall, you need to open the port to allow inbound traffic from an RDP client. In this example, I will allow traffic from my entire subnet to the Ubuntu system.
$ sudo ufw allow from 192.168.2.0/24 to any port 3389
Thereafter, reload the firewall and confirm if the port has been opened.
$ sudo ufw reload $ sudo ufw status
Step 3: Access Remote Ubuntu Desktop with RDP Client
In this step, we are going to access the Ubuntu desktop system from Windows 10 using the Remote Desktop Client. But before we do so, ensure that you first log out of Ubuntu 20.04. This because Xrdp only supports one Xsession.
Next, launch your client and key in your remote system’s IP address, and click the ‘Connect’ button.
On the pop-up that requires you to verify the identity of your remote system, ignore the certificate errors and click on the ‘Next’ button to proceed with the connection.
On the Xrdp login page, provide your login credentials and click ‘Ok’.
NOTE: At this point, you might encounter a blank black screen, instead of an Ubuntu desktop background. In fact, I personally encountered it and after some digging, I discovered a nifty workaround.
Fix Black Ubuntu Screen
The solution is quite simple. Head over to the remote system and edit the /etc/xrdp/startwm.sh script.
$ sudo vim /etc/xrdp/startwm.sh
Add these lines just before the lines that test & execute Xsession as shown in the screenshot below.
unset DBUS_SESSION_BUS_ADDRESS unset XDG_RUNTIME_DIR
Save the file and exit. Then restart the Xrdp service.
$ sudo systemctl restart xrdp
Next, reinitiate the connection. After the initial authentication, you will be required to authenticate again as shown.
Provide your credentials and click ‘Authenticate’ and finally, this ushers you to the desktop screen of the remote Ubuntu desktop system as shown.
We’d love to hear your feedback and, more specifically, the challenges that you encountered. We hope that this guide was useful.