How to Install a Desktop and Xrdp Server (Remote Desktop) on Debian 11 (No oops error)

This article show how to install xrdp on Debian 11. This assumes you have no desktop installed. If you have a desktop, then you can omit the install for it below.

sudo apt update
sudo apt -y install xrdp
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  xorgxrdp
Suggested packages:
  guacamole xrdp-pulseaudio-installer
The following NEW packages will be installed:
  xorgxrdp xrdp
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 506 kB of archives.
After this operation, 3,238 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main amd64 xrdp amd64 0.9.12-1.1 [446                                                                                                                                                             kB]
Get:2 http://deb.debian.org/debian bullseye/main amd64 xorgxrdp amd64 1:0.2.12-1                                                                                                                                                             [59.9 kB]
Fetched 506 kB in 1s (791 kB/s)
Selecting previously unselected package xrdp.
(Reading database ... 141298 files and directories currently installed.)
Preparing to unpack .../xrdp_0.9.12-1.1_amd64.deb ...
Unpacking xrdp (0.9.12-1.1) ...
Selecting previously unselected package xorgxrdp.
Preparing to unpack .../xorgxrdp_1%3a0.2.12-1_amd64.deb ...
Unpacking xorgxrdp (1:0.2.12-1) ...
Setting up xrdp (0.9.12-1.1) ...

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/s                                                                                                                                                            ystemd/system/xrdp.service.
Setting up xorgxrdp (1:0.2.12-1) ...
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for libc-bin (2.31-13+deb11u3) ...
sudo systemctl status xrdp
● xrdp.service - xrdp daemon
     Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-03-26 08:28:09 CDT; 3min 35s ago
       Docs: man:xrdp(8)
             man:xrdp.ini(5)
    Process: 3663 ExecStartPre=/bin/sh /usr/share/xrdp/socksetup (code=exited, status=0/SUCCESS)
    Process: 3671 ExecStart=/usr/sbin/xrdp $XRDP_OPTIONS (code=exited, status=0/SUCCESS)
   Main PID: 3672 (xrdp)
      Tasks: 1 (limit: 4663)
     Memory: 768.0K
        CPU: 17ms
     CGroup: /system.slice/xrdp.service
             └─3672 /usr/sbin/xrdp

Mar 26 08:28:08 testing xrdp[3671]: (3671)(139708485990208)[INFO ] address [0.0.0.0] port [3389] mode 1
Mar 26 08:28:08 testing xrdp[3671]: (3671)(139708485990208)[INFO ] listening to port 3389 on 0.0.0.0
Mar 26 08:28:08 testing xrdp[3671]: (3671)(139708485990208)[INFO ] xrdp_listen_pp done
Mar 26 08:28:08 testing xrdp[3671]: (3671)(139708485990208)[DEBUG] Closed socket 7 (AF_INET6 :: port 3389)
Mar 26 08:28:08 testing systemd[1]: xrdp.service: Can't open PID file /run/xrdp/xrdp.pid (yet?) after start: Operation not permitted
Mar 26 08:28:09 testing systemd[1]: Started xrdp daemon.
Mar 26 08:28:10 testing xrdp[3672]: (3672)(139708485990208)[INFO ] starting xrdp with pid 3672
Mar 26 08:28:10 testing xrdp[3672]: (3672)(139708485990208)[INFO ] address [0.0.0.0] port [3389] mode 1
Mar 26 08:28:10 testing xrdp[3672]: (3672)(139708485990208)[INFO ] listening to port 3389 on 0.0.0.0
Mar 26 08:28:10 testing xrdp[3672]: (3672)(139708485990208)[INFO ] xrdp_listen_pp done
sudo adduser xrdp ssl-cert
Adding user `xrdp' to group `ssl-cert' ...
Adding user xrdp to group ssl-cert
Done.
sudo ufw allow 3389
sudo systemctl restart xrdp

MAKE SURE YOU ARE LOGGED OUT OF THE SERVER TO TEST RDP. NOW RDP TO THE SERVER.

Try to RDP to the server. For Debian 11, The XRDP package results in an error.

The problem seems to happens only with Gnome Desktop. Based the the bug/issue reported to the team behind xrdp software (see https://github.com/neutrinolabs/xorgxrdp/issues/156), the problem is only present when using the xorgxrdp package version 0.2.12. this is a known issue with version xorgxrdp-0.2.12.
The proposed solution is to upgrade to a previous versions xrdp 0.9.15-1 and xorgxrdp 1:0.2.15-1.

These versions are still compatible with libc6 on Debian Bullseye. This is important to note, because I initially tried newer versions of xorgxrdp and xrdp and one of them required a newer version of libc6.

Until a backport is available (mailing list to ask for a backport to bullseye-backports can be found here: https://lists.debian.org/debian-backports/) you can download xrdp 0.9.15-1 and xorgxrdp 1:0.2.15-1 via https://snapshot.debian.org/
Those package versions were still compatible with libc6 from bullseye.

# wget https://snapshot.debian.org/archive/debian/20210302T032219Z/pool/main/x/xorgxrdp/xorgxrdp_0.2.15-1_amd64.deb
# wget https://snapshot.debian.org/archive/debian/20210302T032219Z/pool/main/x/xrdp/xrdp_0.9.15-1_amd64.deb
# sudo apt install ./xorgxrdp_0.2.15-1_amd64.deb
# sudo apt install ./xrdp_0.9.15-1_amd64.deb

Now, RDP should work.