How To Install Xrdp Server On Ubuntu 22.04

One of the first blogs I wrote for turbogeek.co.uk was about installing XRDP on Ubuntu 14.04. Fast-forward over six years, and a lot has changed in the world of XRDP. Not to mention, we are now nine Ubuntu revisions ahead. This demonstrates the rate of change in the IT industry.

So, today’s questions are:

  • Is XRDP still used in 2024?
  • Can you Install XRDP on Ubuntu 22.04?

A Reminder of What is Xrdp?


Xrdp is an open-source remote desktop protocol for Linux that allows users to access their graphical desktops remotely. It’s cross-platform, compatible with RDP clients, supports various Linux desktop environments, and ensures secure encrypted communication. As a community-driven solution, it provides a user-friendly experience for managing Linux systems from different platforms.

Is Xrdp Still Relevent in 2024?

XRDP is frequently maintained and updated. Check out their website here.

All I need now is a desktop version of Ubuntu 22.04. I just so happen to be writing this on a Ubuntu 22.04 laptop. Ta-da!

Bash
echo $XDG_CURRENT_DESKTOP
ubuntu:GNOME
cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS

Guide to Installing Xrdp on Ubuntu 22.04

Here is an easy-to-follow guide for installing xRDP on Ubuntu. Remember to check out how to enable multi-user mode if you are connecting to a shared server.

Step 1 – Update Ubuntu

  • Update Ubuntu Repository; you can optionally upgrade the OS if needed.
Bash
sudo apt-get update -y

sudo apt-get upgrade #optional

Step 2 – Install XRDP

  • Use apt to install the xRDP packages

Bash
sudo apt install xrdp -y

  • You should see this output:

Bash
sudo apt install xrdp
[sudo] password for rbailey: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libhawtjni-runtime-java libjansi-java libjansi-native-java libjline2-java
  python3-cliapp python3-markdown python3-pygments python3-ttystatus
  scala-library scala-parser-combinators scala-xml
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  xorgxrdp
Suggested packages:
  guacamole
The following NEW packages will be installed
  xorgxrdp xrdp
0 to upgrade, 2 to newly install, 0 to remove and 15 not to upgrade.
Need to get 582 kB of archives.
After this operation, 3,380 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://gb.archive.ubuntu.com/ubuntu jammy/universe amd64 xrdp amd64 0.9.17-2ubuntu2 [517 kB]
Get:2 http://gb.archive.ubuntu.com/ubuntu jammy/universe amd64 xorgxrdp amd64 1:0.2.17-1build1 [65.3 kB]
Fetched 582 kB in 0s (2,756 kB/s)  
Selecting previously unselected package xrdp.
(Reading database ... 243766 files and directories currently installed.)
Preparing to unpack .../xrdp_0.9.17-2ubuntu2_amd64.deb ...
Unpacking xrdp (0.9.17-2ubuntu2) ...
Selecting previously unselected package xorgxrdp.
Preparing to unpack .../xorgxrdp_1%3a0.2.17-1build1_amd64.deb ...
Unpacking xorgxrdp (1:0.2.17-1build1) ...
Setting up xrdp (0.9.17-2ubuntu2) ...

Generating 2048 bit rsa key...

ssl_gen_key_xrdp1 ok

saving to /etc/xrdp/rsakeys.ini

Created symlink /etc/systemd/system/multi-user.target.wants/xrdp-sesman.service 
 /lib/systemd/system/xrdp-sesman.service.
Created symlink /etc/systemd/system/multi-user.target.wants/xrdp.service  /lib/
systemd/system/xrdp.service.
Setting up xorgxrdp (1:0.2.17-1build1) ...
Processing triggers for man-db (2.10.2-1) ...#####..........................] 
Processing triggers for libc-bin (2.35-0ubuntu3.6) ...

  • You can check that XRDP is running by typing:

Bash
sudo systemctl status xrdp

  • You should see output like this:

Bash
sudo systemctl status xrdp
 xrdp.service - xrdp daemon
     Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2024-01-23 21:32:50 GMT; 1min 19s ago
       Docs: man:xrdp(8)
             man:xrdp.ini(5)
    Process: 9815 ExecStartPre=/bin/sh /usr/share/xrdp/socksetup (code=exited, status=0/SUCCESS)
    Process: 9823 ExecStart=/usr/sbin/xrdp $XRDP_OPTIONS (code=exited, status=0/SUCCESS)
   Main PID: 9824 (xrdp)
      Tasks: 1 (limit: 37961)
     Memory: 956.0K
        CPU: 26ms
     CGroup: /system.slice/xrdp.service
             └─9824 /usr/sbin/xrdp

Jan 23 21:32:49 ichard-bailey systemd[1]: Starting xrdp daemon...
Jan 23 21:32:49 richard-bailey xrdp[9823]: [INFO ] address [0.0.0.0] port [3389] mode 1
Jan 23 21:32:49 richard-bailey xrdp[9823]: [INFO ] listening to port 3389 on 0.0.0.0
Jan 23 21:32:49 richard-bailey xrdp[9823]: [INFO ] xrdp_listen_pp done
Jan 23 21:32:49 richard-bailey systemd[1]: xrdp.service: Can't open PID file /run/xrdp/>
Jan 23 21:32:50 systemd[1]: Started xrdp daemon.
Jan 23 21:32:51 richard-bailey xrdp[9824]: [INFO ] starting xrdp with pid 9824
Jan 23 21:32:51 richard-bailey xrdp[9824]: [INFO ] address [0.0.0.0] port [3389] mode 1
Jan 23 21:32:51 rchard-bailey xrdp[9824]: [INFO ] listening to port 3389 on 0.0.0.0
Jan 23 21:32:51 richard-bailey xrdp[9824]: [INFO ] xrdp_listen_pp done

Step 3 – Configure SSL

This is a new feature from when I last tested this six years ago—more evidence of how times have changed quickly.

Bash
sudo adduser xrdp ssl-cert

  • Now restart the XRDP service.

Bash
sudo systemctl restart xrdp

  • Now Add a Firewall Rule to allow inbound and outbound traffic on port 3389

Bash
sudo ufw allow from 192.168.0.0/24 to any port 3389
sudo ufw allow 3389

Note: My Windows PC, which I will use to test this, is on my local network, 192. x.x.x. If you are following along, you must change this value to what’s relevant.

Step 4 – Test the XRDP connection

I have now switched over to my Windows PC.

  • The first step is to open Remote Desktop Connection (MSTSC)

For Windows:

  1. Search for “Remote Desktop Connection”: You can do this by typing “Remote Desktop Connection” in the Windows search bar.
  2. Open the Remote Desktop Connection application: Click on the application in the search results.
  3. Enter the Computer’s IP Address or Hostname: In the Remote Desktop Connection window, you’ll need to enter the IP address or hostname of the computer you want to connect to.
  4. Click “Connect”: Once you’ve entered the required information, click the “Connect” button.
  5. Enter Credentials: You’ll be prompted to enter the username and password for the computer you are connecting to. Ensure you have the correct credentials.
  6. Connect: After entering the credentials, click “OK” or “Connect” to establish the RDP connection.

For Mac:

  1. Download Microsoft Remote Desktop from the App Store: If you don’t have it already, you can download the Microsoft Remote Desktop application from the Mac App Store.
  2. Open Microsoft Remote Desktop: Once installed, open the application.
  3. Click on “New”: To create a new connection, click on the “+” icon or select “New” from the File menu.
  4. Enter Connection Details: Enter the PC name or IP address, and configure other settings as needed.
  5. Save the Connection: Click “Add” to save the connection.
  6. Connect: Select the newly created connection and click “Start” to initiate the RDP session.
Elsewhere On TurboGeek:  Published Writing

Step 5 – Initiate an RDP connection

  • Use the remote desktop connection tool to connect to your Ubuntu server.
  • You can use the RDP or the FQDN if a home network is enabled.

  • When you get this warning, click YES.

  • After a few seconds, you should connect to the Ubuntu machine.
  • This is the login prompt you will get:

  • Enter your Username and Password for the Ubuntu Machine

IMPORTANT: If you get this message (see below), you have mistyped your details or logged in to an active session (someone else is logged on) – Sometimes, you may get a BLACK screen. To fix you need to enable multi-user mode, again, see below:

Step 6 – Enable Multi-User Mode

  • Install D-BUS

dbus-x11 is a software package that provides a D-Bus session bus for each X11 display, facilitating inter-process communication between applications running under the X11 window system.

Bash
sudo apt-get install dbus-x11

  • Modify the startwm.sh file

Bash
sudo nano /etc/xrdp/startwm.sh

Add the following:

test -x /etc/X11/Xsession && exec /etc/X11/Xsession.

Before:

#!/bin/sh
# xrdp X session start script (c) 2015, 2017, 2021 mirabilos
# published under The MirOS Licence

# Rely on /etc/pam.d/xrdp-sesman using pam_env to load both
# /etc/environment and /etc/default/locale to initialise the
# locale and the user environment properly.

if test -r /etc/profile; then
	. /etc/profile
fi
exec /bin/sh /etc/X11/Xsession

After:

#!/bin/sh
# xrdp X session start script (c) 2015, 2017, 2021 mirabilos
# published under The MirOS Licence

# Rely on /etc/pam.d/xrdp-sesman using pam_env to load both
# /etc/environment and /etc/default/locale to initialise the
# locale and the user environment properly.

if test -r /etc/profile; then
	. /etc/profile
fi

test -x /etc/X11/Xsession && exec /etc/X11/Xsession
exec /bin/sh /etc/X11/Xsession

  • Next, run this command:
Bash
export $(dbus-launch)

  • Your output should look like this:

Bash
#!/bin/sh
# xrdp X session start script (c) 2015, 2017 mirabilos
# published under The MirOS Licence

if test -r /etc/profile; then
    . /etc/profile
fi

if test -r /etc/default/locale; then
    . /etc/default/locale
    test -z "${LANG+x}" || export LANG
    test -z "${LANGUAGE+x}" || export LANGUAGE
    test -z "${LC_ADDRESS+x}" || export LC_ADDRESS
    test -z "${LC_ALL+x}" || export LC_ALL
    test -z "${LC_COLLATE+x}" || export LC_COLLATE
    test -z "${LC_CTYPE+x}" || export LC_CTYPE
    test -z "${LC_IDENTIFICATION+x}" || export LC_IDENTIFICATION
    test -z "${LC_MEASUREMENT+x}" || export LC_MEASUREMENT
    test -z "${LC_MESSAGES+x}" || export LC_MESSAGES
    test -z "${LC_MONETARY+x}" || export LC_MONETARY
    test -z "${LC_NAME+x}" || export LC_NAME
    test -z "${LC_NUMERIC+x}" || export LC_NUMERIC
    test -z "${LC_PAPER+x}" || export LC_PAPER
    test -z "${LC_TELEPHONE+x}" || export LC_TELEPHONE
    test -z "${LC_TIME+x}" || export LC_TIME
    test -z "${LOCPATH+x}" || export LOCPATH
fi

if test -r /etc/profile; then
    . /etc/profile
fi

export $(dbus-launch)

test -x /etc/X11/Xsession && exec /etc/X11/Xsession
exec /bin/sh /etc/X11/Xsession

  • Now reboot the Ubuntu Machine

Bash
sudo reboot

That is it; reconnect to your Ubuntu Server, and you will get a new desktop even if the server (or laptop) is already in use.

We welcome all feedback. Please comment below.

Thanks for taking the time to read this article. if you have any questions or feedback, please write in the comment section below.

Richard.Bailey

Richard Bailey, a seasoned tech enthusiast, combines a passion for innovation with a knack for simplifying complex concepts. With over a decade in the industry, he's pioneered transformative solutions, blending creativity with technical prowess. An avid writer, Richard's articles resonate with readers, offering insightful perspectives that bridge the gap between technology and everyday life. His commitment to excellence and tireless pursuit of knowledge continues to inspire and shape the tech landscape.

You may also like...

9 Responses

  1. Giuseppe says:

    Thank you for the thorough guide. I can successfully connect from Windows to Ubuntu 22.04. However, I cannot connect from Mac. I am using Microsoft Remote Desktop client as you suggested. When i click on “connect” the application asks me for my user name and password and i cannot leave them blank (like in Windows is possible), I insert the credentials and it hangs trying to connecting saying: “Configuring remote pc”.

    Do you have any experience that you can share?

  2. Pawel says:

    RDP works great. Thank you.

    However, multi-user mode does not work.
    I can still only have one session.
    I installed Ubuntu 22.04.3 LTS, configured and did everything as you suggested.
    Is there anything else I should do or check?

  3. Pawel says:

    I found the solution at https://c-nergy.be/blog/?p=16698
    Workaround 3 works

  4. Hi,

    If you are using Windows and want to RDP Ubuntu VM using Hyper V virtualization then please see my detailed answer on https://askubuntu.com/a/1503875/1751721

    The steps are staright forward and no new installation is required.

    Best Regards,
    Syed Nasir Abbas

  5. arjw says:

    I’m currently observing behavior where the connection is successful according to the logs but is dropped by the Windows RDP client as soon as the credentials are submitted. Any suggestions?

    • The first thing i would try is to eliminate the chance this is being caused by the Windows Firewall.
      Disable the Windows firewall on the target machine. Try again. There is a good chance that this will fix it, if it does enable the firewall and manually add an outbound rule for 3389.
      If it doesnt work. Try the basics, updates windows, reboot windows, reboot router.
      If it still fails, copy the logs here and I will take another look for you.

      Thanks for reading.
      Richard aka TurboGeek

  1. 24/01/2024

    […] Looking to Install XRDP on Ubuntu 22.04? Check out our new guide here. […]

Leave a Reply

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

Translate »