Setup Remote Desktop Connection on Ubuntu with xrdp

This brief tutorial shows students and new users how to setup Remote Desktop Connection (RDP) on Ubuntu 20.04 | 18.04 with xrdp.

xrdp is an open source implementation of Microsoft Remote Desktop Connection (RDP) on Linux systems, including Ubuntu desktop. It provides graphical login to remote systems using RDP protocols.

xrdp also enables two-way clipboard transfer, audio and drives redirection, accepts connections from variety of RDP clients: FreeRDP, rdesktop, NeutrinoRDP and Microsoft Remote Desktop Client.

For students and new users running Ubuntu desktop and want to connect to it via RDP, xrdp is the app to use in this case.

For more about xrdp, please visit its homepage.

To get started with installing and configuring xrdp on Ubuntu, follow the steps below:

Install xrdp on Ubuntu

xrdp works on desktop systems. You won’t be able to connect to systems without a desktop environment. On Ubuntu servers, you must install a desktop environment before using xrdp.

xrdp is available in Ubuntu default repositories. No need to add additional repositories to install. Simply run the commands below from the terminal to install it.

sudo apt update
sudo apt install xrdp

After installing, run the commands below to verify that it is installed and running.

sudo systemctl status xrdp

You should see similar result as shown below:

 xrdp.service - xrdp daemon
     Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2021-06-13 09:43:03 CDT; 1min 53s ago
       Docs: man:xrdp(8)
             man:xrdp.ini(5)
   Main PID: 37933 (xrdp)
      Tasks: 1 (limit: 4653)
     Memory: 1.1M
     CGroup: /system.slice/xrdp.service
             └─37933 /usr/sbin/xrdp

Jun 13 09:43:02 ubuntu2004 xrdp[37932]: (37932)(139757869672256)[INFO ] address [0.0.0.0] port>
Jun 13 09:43:02 ubuntu2004 xrdp[37932]: (37932)(139757869672256)[INFO ] listening to port 3389>

Configuring xrdp

Now that you have xrdp installed on Ubuntu, configure it to make it so that connections can be made without facing numeral issues.

First, add xrdp user account to the ssl-cert certificate key file groups. By default xrdp uses the /etc/ssl/private/ssl-cert-snakeoil.key file which is readable only by users that are members of the “ssl-cert” group.

The ssl-cert key file plays an important role in connecting via remote desktop on Ubuntu.

sudo adduser xrdp ssl-cert 

Ouput:

Adding user xrdp' to groupssl-cert' …
Adding user xrdp to group ssl-cert
Done.

Next, add these lines into xrdp startup script to make help resolve some situations where users’ screens have black backgrounds.

Open the startup script file.

sudo nano /etc/xrdp/startwm.sh 

Than add these lines to the end file and save.

Unset DBUS_SESSION_ADDRESS
Unset XDG_RUNTIME_DIR

Save the file and exit.

Restart xrdp service.

sudo systemctl restart xrdp 

Make sure firewall isn’t enabled and blocking port 3389.

sudo ufw allow from 10.0.2.0/24 to any port 3389
sudo ufw reload  

Replace the highlighted subnet with your own.

Log out of Ubuntu. Make sure you’re not already logged in to Ubuntu while attempting to connect via Remote Desktop Connation. You can’t be logged in to Ubuntu while you connect via RDP.

Connect to Ubuntu

Now try connecting to Ubuntu via Remote Desktop Protocol (RDP).

Type in your username and password for the Ubuntu system.

That’s it!

Conclusion:

This post showed you how to install and configure xrdp to provide remote desktop connection to Ubuntu. If you find any error above, please use the comment form below to report.

You may also like the post below:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.