Fix of two blockers of RDP to Ubuntu VM from Windows machines
Note 1: remember to restart xrdp after each of your repair attempts: sudo systemctl restart xrdp
Note 2: before you try out repair below, make sure your firewall is not blocking 3389 (used by xrdp) or 3350 (used by xrdp-sesman).
Introduction of the configurations
- VM Host: HyperV on Windows 11
- VM Image: Ubuntu 18.04 TLS
Problem 1: xrdp cannot listen on 3389
command to verify this issue: sudo ss -tulpn | grep 3389
If the command above should return something like below:
tcp LISTEN 0 2 *:3389 : users:((“xrdp”,pid=942,fd=11)
Otherwise, it means xrdp is experiencing to listen on 3389
steps to fix problem 1
Approach 1. setup network connection profile to ensure ubuntu has a valid IPv4 address
This can be done by editing the /etc/netplan/01-{YOUR NETWORK MANAGER CONFIG}.yaml:
First try the dhcp:
eth0:
dhcp4: true
Another nuclear way is to assign a static IP address (maybe for a temporary option).
**Make sure you change the addresses and gateway4 config to your own values and remember ymal is picky about indentation (which has been lost in this post’s format) **
ethernets:
eth0:
dhcp4: no
addresses:
- 192.168.0.126/24
gateway4: 192.168.0.1
nameservers:
addresses:
- 8.8.8.8
- 1.1.1.1
Approach 2. disable use_vsock
Check your xrdp.ini and make sure use_vsock is set to false.
Approach 3. ensure availability of snakeoil cert
If you see error in xrdp log like “cannot find /etc/xrdp/cert.pem or /etc/xrdp/key.pem”, most likely these files are not set up yet. You can create them with command below:
sudo make-ssl-cert generate-default-snakeoil --force-overwrite
the .pem files used by xrdp are sym links to /etc/ssl/certs/ssl-cert-snakeoil.pem and /etc/ssl/private/ssl-cert-snakeoil.key. If the files already exists under /etc/ss/certs and /etc/ssl/private, you then need to check the permission to access them by user xrdp.
Problem 2. Blank screen after Connect
Symptom of this issue
You see a blank desktop background or you see a small pop up window saying “connection problem” after you login the remote Ubuntu machine.
And if you check xrdp log (using command: sudo journalctl -u xrdp -f for xrdp and sudo journalctl -u xrdp-sesman -f for xrdp-sesman) , you see many lines of “xrdp closed socket 17 af_unix”
Approach 1 Install xfce4 and set it as the default session for rdp
Installation:
sudo apt update
sudo apt install xfce4 xfce4-goodies
Set as default:
Option 1:
echo "xfce4-session" > ~/.xsession
If Option 1 didn’t work as expected:
Option 2: modify the /etc/xrdp/startwm.sh file to explicitly use xfce4-session. Comment out any lines that start a different desktop environment (like gnome-session or unity-session) and add the following line:
exec /usr/bin/xfce4-session
Approach 2 Install xserver-xorg-core instead of xserver-xorg-core-hwe
sudo -i
apt install xserver-xorg-core
apt install xorgxrdp
service xrdp restart
In case you are still seeing any issues with all the repairs attempted (and double checked your firewall settings), you can reply to this post with your xrdp and xrdp-sesman logs and we can look at them together.