In this article, we want to teach you how to Install and Configure XRDP on Ubuntu 20.04.
XRDP is a free and open-source implementation of the Microsoft RDP (Remote Desktop Protocol) server that enables operating systems other than Microsoft Windows (such as Linux and BSD-style operating systems) to provide a fully functional RDP-compatible remote desktop experience.
Steps To Install and Configure XRDP on Ubuntu 20.04
In this article, you learn to install XRDP on Ubuntu 20.04, you also learn to install a Desktop environment on your system.
To do these, you need some requirements first.
You need to log in to your server as a non-root user with sudo privileges and set up a basic firewall. You can follow our article about the Initial Server Setup with Ubuntu 20.04.
When you are done, you can start to install the Desktop environment on your system.
Install Desktop environment on Ubuntu 20.04
XRDP server is designed to control only desktop systems. The Desktop environment is not available on Ubuntu by default.
You need to add a Desktop environment to your system.
First of all, update and upgrade your local package index with the following command:
sudo apt update && sudo apt upgrade
Then, install the Tasksel utility to install a Desktop environment on Ubuntu 20.04 with the following command:
sudo apt install tasksel -y
Now you need to launch the Tasksel with the following command:
You will see the package configuration:
Find the Ubuntu desktop by using the arrow keys. Press space to select it and then press tab to select ok and hit enter to install the Ubuntu desktop.
Now you need to set your system boots into the graphical target. you can use the following command:
systemctl set-default graphical.target
Then, you need to restart your system to apply these changes.
Let’s start to install XRDP.
Install XRDP on Ubuntu 20.04
The XRDP packages are available in the Ubuntu 20.04 default repository. To install it you can use the following command:
sudo apt install xrdp -y
When your installation is finished, verify that you have installed it successfully with the following command:
sudo systemctl status xrdp
In your output you should see:
Output xrdp.service - xrdp daemon Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2021-11-04 10:43:24 CET; 49s ago Docs: man:xrdp(8) man:xrdp.ini(5) Main PID: 3108 (xrdp) Tasks: 1 (limit: 2273) Memory: 1.2M CGroup: /system.slice/xrdp.service └─3108 /usr/sbin/xrdp
This means that the XRDP on Ubuntu 20.04 is active and running.
Let’s start to configure XRDP.
Configure XRDP on Ubuntu 20.04
From the installation, XRDP added a user named “xrdp”. The xrdp session uses a certificate key file “/etc/ssl/private/ssl-cert-snakeoil.key”.
You need to add the xrdp user to the “ssl-cert” group with the following command:
sudo usermod -a -G ssl-cert xrdp
Now you need to edit the /etc/xrdp/startwm.sh file. Open the XRDP file on Ubuntu 20.04 with your favorite text editor, here we use vi:
sudo vi /etc/xrdp/startwm.sh
Add the following commands before the commands that test & execute Xsession:
Unset DBUS_SESSION_ADDRESS Unset XDG_RUNTIME_DIR
... if test -r /etc/profile; then . /etc/profile fi Unset DBUS_SESSION_ADDRESS Unset XDG_RUNTIME_DIRUnset test -x /etc/X11/Xsession && exec /etc/X11/Xsession exec /bin/sh /etc/X11/Xsession
When you are done, save and close the file.
Restart XRDP on Ubuntu 20.04
To apply these changes restart XRDP on Ubuntu 20.04 with the following command:
sudo systemctl restart xrdp
Here you need to adjust the firewall to allow access to port 3389 for remote systems.
To do this you can use the following command:
sudo ufw allow 3389
If you want to open port 3389 for the LAN network, you can use the following command instead:
sudo ufw allow from 192.168.1.0/24 to any port 3389
Now reload the firewall to apply the new rules:
sudo ufw reload
At this point, when you are done with the XRDP configuration on Ubuntu 20.04, you can connect to the remote desktop.
Connect To Ubuntu Remote Desktop
On your Windows client, open the RDP client and enter the IP address of the Ubuntu system.
You can use Winkey+R to open the Run window and type the “mstsc” in it to open the RDP client.
After you click connect, you will receive a warning that the remote system is unknown to your system. click on the “Don’t ask me again for connection to this computer” and press yes to continue.
After this, you will be asked to enter your Ubuntu credentials. Enter the login credentials of the remote Ubuntu 20.04 system to get remote desktop access with Xrdp.
Now you will get remote desktop access.
Here you can manage your remote Ubuntu 20.04 graphically.
At this point, you learn to Install and Configure XRDP on Ubuntu 20.04. Also, you learn to set up an Ubuntu desktop environment.
Hope you enjoy it.
You may be like these articles: