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:  How to deploy a VPS On Atlantic.Net

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...

19 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

  6. Abbey says:

    Hi, thanks for the post. I followed your instructions but I got this message on a blank white screen after entering the right credentials. – “Oh no! Something has gone wrong. A problem has occured and the system can’t recover. Please log out and try again.”

    I retried but to no avail. What could be the issue?

    Regards,
    Abbey

    • Its difficult to say, can you send me the output from your log files, be sure to redact any sensitive information:

      cat /var/log/xrdp-sesman.log

      • Abbey says:

        This is the output from the log file. Thanks!

        [20240822-15:37:10] [INFO ] starting xrdp-sesman with pid 575
        [20240822-15:37:39] [INFO ] Socket 8: AF_INET6 connection received from ::1 port 51666
        [20240822-15:37:39] [INFO ] Terminal Server Users group is disabled, allowing authentication
        [20240822-15:37:39] [INFO ] ++ created session (access granted): username xrdp, ip ::ffff:x.x.x.x:58076 – socket: 12
        [20240822-15:37:39] [INFO ] starting Xorg session…
        [20240822-15:37:39] [INFO ] Starting session: session_pid 1611, display :10.0, width 1920, height 1080, bpp 24, client ip ::ffff:x.x.x.x:58076 – socket: 12, user name xrdp
        [20240822-15:37:39] [INFO ] [session start] (display 10): calling auth_start_session from pid 1611
        [20240822-15:37:39] [ERROR] sesman_data_in: scp_process_msg failed
        [20240822-15:37:39] [ERROR] sesman_main_loop: trans_check_wait_objs failed, removing trans
        [20240822-15:37:39] [INFO ] Starting X server on display 10: /usr/lib/xorg/Xorg :10 -auth .Xauthority -config xrdp/xorg.conf -noreset -nolisten tcp -logfile .xorgxrdp.%s.log
        [20240822-15:37:39] [INFO ] Found X server running at /tmp/.X11-unix/X10
        [20240822-15:37:39] [INFO ] Session started successfully for user xrdp on display 10
        [20240822-15:37:39] [INFO ] Session in progress on display 10, waiting until the window manager (pid 1623) exits to end the session
        [20240822-15:37:39] [INFO ] Starting the xrdp channel server for display 10
        [20240822-15:37:39] [INFO ] Found X server running at /tmp/.X11-unix/X10
        [20240822-15:37:39] [INFO ] Found X server running at /tmp/.X11-unix/X10
        [20240822-15:37:39] [INFO ] Starting the default window manager on display 10: /etc/xrdp/startwm.sh
        [20240822-15:37:49] [INFO ] Calling auth_stop_session and auth_end from pid 1611
        [20240822-15:37:49] [INFO ] Terminating X server (pid 1624) on display 10
        [20240822-15:37:49] [INFO ] Terminating the xrdp channel server (pid 1636) on display 10
        [20240822-15:37:49] [INFO ] X server on display 10 (pid 1624) returned exit code 0 and signal number 0
        [20240822-15:37:49] [INFO ] xrdp channel server for display 10 (pid 1636) exit code 0 and signal number 0
        [20240822-15:37:49] [INFO ] cleanup_sockets:
        [20240822-15:37:49] [INFO ] ++ terminated session: username xrdp, display :10.0, session_pid 1611, ip ::ffff:x.x.x.x:58076 – socket: 12

        • The key line is:

          [20240822-15:37:39] [ERROR] sesman_data_in: scp_process_msg failed

          This error suggests a problem in the communication between the xrdp session manager (sesman) and the client. When scp_process_msg fails, it can lead to the session being terminated abruptly
          My guess is that your target firewall is causing this. If possible, disable the firewall to test (port 3398) – that will give you a yes or no answer.

          Otherwise, it could be XRDP configuration – Misconfigurations in session management settings, such as maximum sessions or idle timeout, can terminate sessions.
          Check in Configuration: Look for settings like max_sessions, idle_timeout, or disconnected_session_timeout in /etc/xrdp/sesman.ini. Adjust these if necessary to allow sufficient time for connection

          • Abbey says:

            I tried to troubleshoot using the above instructions and other guidelines I saw online, but to no avail. So I installed/configured the Xfce desktop environment and the remote connection to the Ubuntu VM worked successfully.
            Thank you!

          • zzzhhh says:

            I got the same errors as Abbey. The screen is all black. There is no firewall turned on; “sudo ufw status” returns “Status: inactive”. I checked “/etc/xrdp/sesman.ini” and I believe all parameters are default and correct. Now what?

  7. mp3 quack says:

    Great step-by-step guide! I followed your instructions and successfully installed XRDP on my Ubuntu 22.04 server. Thanks for making it so clear and easy to understand!

  8. Amit says:

    alston@alston:~$ systemctl status xrdp
    × xrdp.service – xrdp daemon
    Loaded: loaded (/usr/lib/systemd/system/xrdp.service; enabled; preset: enabled)
    Active: failed (Result: exit-code) since Fri 2024-12-13 16:39:35 IST; 11min ago
    Docs: man:xrdp(8)
    man:xrdp.ini(5)
    CPU: 48ms

    Dec 13 16:39:35 alston systemd[1]: Starting xrdp.service – xrdp daemon…
    Dec 13 16:39:35 alston xrdp[48496]: [INFO ] address [0.0.0.0] port [3389] mode 1
    Dec 13 16:39:35 alston xrdp[48496]: [INFO ] listening to port 3389 on 0.0.0.0
    Dec 13 16:39:35 alston xrdp[48496]: [ERROR] g_tcp_bind(7, 3389) failed bind IPv6 (errno=98) and IPv4 (errno=22).
    Dec 13 16:39:35 alston xrdp[48496]: [ERROR] trans_listen_address failed
    Dec 13 16:39:35 alston xrdp[48496]: [CORE ] Failed to start xrdp daemon, possibly address already in use.
    Dec 13 16:39:35 alston systemd[1]: xrdp.service: Control process exited, code=exited, status=1/FAILURE
    Dec 13 16:39:35 alston systemd[1]: xrdp.service: Failed with result ‘exit-code’.
    Dec 13 16:39:35 alston systemd[1]: Failed to start xrdp.service – xrdp daemon.
    alston@alston:~$

    • Hi Amit

      The key information here is that something on your system is already using port 3389

      Dec 13 16:39:35 alston xrdp[48496]: [ERROR] g_tcp_bind(7, 3389) failed bind IPv6 (errno=98) and IPv4 (errno=22).
      Dec 13 16:39:35 alston xrdp[48496]: [CORE ] Failed to start xrdp daemon, possibly address already in use.

      This command should tell you what is using the port

      sudo lsof -i tcp:3389

      You need to then make a decision to kill what’s already running on that port, or configure XRPP to use another port.

      Let me know how you get on

      Richard

  9. Amit says:

    please provide solution for same

  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 »