Xrdp on Ubuntu 20.04

I installed Ubuntu 20.04 and then installed xrdp. Whenever i tried to connect, either from another Ubuntu 20.04 box using either xfreerdp or krdc, or from a Mac, a black screen would show up, and then immediately disconnect. i made sure i did not have any other sessions on the server going on at the same time.

After a while, i gave up and tried the script at: https://www.c-nergy.be/products.html it didn't make a difference

this is the only output from /var/log/xrdp.log

[20200529-18:17:16] [INFO ] Socket 12: AF_INET6 connection received from ::ffff:192.168.0.216 port 45006 
[20200529-18:17:16] [DEBUG] Closed socket 12 (AF_INET6 ::ffff:192.168.0.199 port 3389) 
[20200529-18:17:16] [DEBUG] Closed socket 11 (AF_INET6 :: port 3389) 
[20200529-18:17:16] [INFO ] Using default X.509 certificate: /etc/xrdp/cert.pem 
[20200529-18:17:16] [INFO ] Using default X.509 key file: /etc/xrdp/key.pem 
[20200529-18:17:16] [DEBUG] TLSv1.3 enabled 
[20200529-18:17:16] [DEBUG] TLSv1.2 enabled 
[20200529-18:17:16] [DEBUG] Security layer: requested 3, selected 1 
[20200529-18:17:16] [INFO ] connected client computer name: coruscant 
[20200529-18:17:16] [INFO ] adding channel item name cliprdr chan_id 1004 flags 0xc0a00000 
[20200529-18:17:16] [INFO ] TLS connection established from ::ffff:192.168.0.216 port 45006: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 
[20200529-18:17:16] [DEBUG] xrdp_00000506_wm_login_mode_event_00000001 
[20200529-18:17:16] [INFO ] Loading keymap file /etc/xrdp/km-00000409.ini 
[20200529-18:17:16] [WARN ] local keymap file for 0x00000409 found and doesn't match built in keymap, using local keymap file 
[20200529-18:17:17] [DEBUG] Closed socket 12 (AF_INET6 ::ffff:192.168.0.199 port 3389) 
[20200529-18:17:17] [DEBUG] xrdp_mm_module_cleanup

thank you very much


Solution 1:

I was able to solve this issue by logging out of the desktop session for the machine before trying RDP.

Solution 2:

I'd faced the same issue in my local server Ubuntu 20.04 (Installed xubuntu-desktop) and I had fixed it by executing the following command.

# echo "startxfce4" > ~/.Xsession
# chmod +x ~/.xsession
# sudo systemctl restart xrdp.service

If you get a Warning Message [Authentication is required to create a color managed device] while connecting to the Ubuntu server through Xrdp, you need to execute the following commands to ignore it:

# cd /usr/share/polkit-1/actions/

# vi org.freedesktop.color.policy

Modify <allow_any> settings from auth_admin to yes.

<defaults> 
      <allow_any>yes</allow_any>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
</defaults>

# reboot 

Solution 3:

1. Remove previously installed xrdp:

$ sudo systemctl disable xrdp
$ sudo systemctl stop xrdp

$ sudo apt purge xrdp
$ sudo apt purge xserver-xorg-core
$ sudo apt purge xserver-xorg-input-all
$ sudo apt purge xorgxrdp

2. Re-install xrdp & required packages:

$ sudo apt install xrdp
$ sudo apt install xserver-xorg-core
$ sudo apt install xserver-xorg-input-all
$ sudo apt install xorgxrdp

You also need to grant access to the /etc/ssl/private/ssl-cert-snakeoil.key file for xrdp user. It is available to members of the ssl-cert group by default.

$ sudo adduser xrdp ssl-cert           # add xrdp into ssl-cert group
$ sudo systemctl start xrdp            # start xrdp service
$ systemctl is-active xrdp             # check xrdp state
...
active
$ sudo systemctl enable xrdp           # start xrdp on system start

3. Reboot system:

$ sudo reboot

4. Firewall configuration:

You need to open access on port 3389.

$ sudo ufw allow 3389

It is more secure to open it only for your IP address or network. For example:

$ sudo ufw allow from 10.5.5.0/24 to any port 3389

The best practice is to use an SSH tunnel to connect to the remote desktop and make xRDP listen only for local connections.

5. Setup your RDP-client

Please note that in some cases the user who will connect to xRDP must log out before doing so!

  • Connect to your server using any RDP client.
  • Enter the user credentials of your Ubuntu computer.
  • Now you can see the remote desktop initial screen.

Related commands:

$ sudo systemctl status xrdp           # display current xrdp status

$ sudo systemctl start xrdp            # start xrdp service
$ sudo systemctl stop xrdp             # stop xrdp service
$ sudo systemctl restart xrdp          # restart xrdp service

$ sudo systemctl enable xrdp           # enable xrdp on system start
$ sudo systemctl disable xrdp          # disable xrdp on system start

Solution 4:

After many tries and some fixes I was able to rdp but:

  1. Password was requested way to many times
  2. Side bar didn't fill up the whole screen

So I found this xRDP installation script that works perfectly! Credits to Griffon!!

Just download, unzip and run:

wget https://www.c-nergy.be/downloads/xrdp-installer-1.2.2.zip
unzip xrdp-installer-1.2.2.zip 
bash xrdp-installer-1.2.2.sh

Solution 5:

It seems to be possible to allow multiple sessions so that you don't have to logout or end up in the blackscreen. Worked on my 20.04 LTS just by adding two lines into the startwm.sh.

nano /etc/xrdp/startwm.sh

Add in the very top:

unset DBUS_SESSION_BUS_ADDRESS
unset XDG_RUNTIME_DIR

then:

sudo systemctl restart xrdp

Credits to Peter Bennett @catch22cats, thanks!