https://linuxize.com/post/how-to-install-xrdp-on-ubuntu-20-04/
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.
Prerequisites 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
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.
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
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.
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.