RDP Installation and Configuration Guide (Debian/Ubuntu)

🧭 Two lines decide everything

An xrdp setup works or fails on two details, and both fail silently:

LineDecidesIf it is missing
~/.xsessionwhich desktop the RDP session startsyou get the system’s default desktop
adduser xrdp ssl-certwhether the connection is encrypted with TLSit still connects, with the old RDP security instead of TLS

Everything else is installing packages.

📦 Install

sudo apt update
sudo apt install xrdp xfce4 xfce4-goodies

On the test machine these three packages were enough: xorgxrdp (the X server for RDP sessions) comes with xrdp. No ubuntu-desktop is needed, and on Debian it does not exist.

🖥️ Choose the desktop: ~/.xsession

# As the user who will connect over RDP, not as root
echo xfce4-session > ~/.xsession

At login xrdp runs /etc/xrdp/startwm.sh, which hands over to /etc/X11/Xsession, which reads ~/.xsession. It is a per-user file: each user who connects over RDP needs their own.

What happened in the test, three variants:

exec startxfce4 in xrdp.ini~/.xsessionDesktop that started
yesyesXFCE
noyesXFCE
yesnoLXQt (the machine’s default)

So the line that many guides (this one included, in its first version) append to /etc/xrdp/xrdp.ini does nothing: that file is an INI file, not a script.

XFCE desktop served over RDP, seen from the client window

🔒 TLS: the ssl-cert group

xrdp runs as the user xrdp and uses the system’s “snakeoil” certificate, whose key sits in /etc/ssl/private: readable only by root and by the ssl-cert group. In the test, right after the installation xrdp was not in that group, and every connection went like this:

[ERROR] Cannot read private key file /etc/xrdp/key.pem: Permission denied
[WARN ] Cannot accept TLS connections because certificate or private key file is not readable. ...
[INFO ] Security protocol: configured [RDP], requested [SSL|HYBRID|RDP], selected [RDP]

The client connected anyway. Nothing on screen says that TLS is off. After:

sudo adduser xrdp ssl-cert
sudo systemctl restart xrdp

the same connection reads:

[INFO ] Security protocol: configured [SSL|RDP], requested [SSL|HYBRID|RDP], selected [SSL]
[INFO ] TLS connection established from ::ffff:127.0.0.1 port 39446: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384

To check yours, connect once and then:

sudo grep -E "Security protocol|TLS connection|private key" /var/log/xrdp.log | tail -3

🔥 Do not leave port 3389 open to the world

The best way is not to open it at all and go through SSH, which you probably already have:

# On the client: local port 13389 -> port 3389 of the server, inside SSH
ssh -N -L 13389:localhost:3389 user@server

# Then point the RDP client at localhost:13389

In the test xrdp saw the session arrive from 127.0.0.1, the far end of the tunnel, with TLS on top: two layers of encryption, and only port 22 exposed. (Port 13389 avoids a clash with 3389 on a Windows client that has its own Remote Desktop on.)

If it must be reachable directly, limit it to the local network:

# Only from the local network, never from everywhere
sudo ufw allow from 192.168.1.0/24 to any port 3389 proto tcp
sudo ufw status

📜 Everything in one script

#!/bin/bash
# Run as the user who will connect over RDP (sudo is used where needed)
set -e
sudo apt update -qq
sudo apt install -y -qq xrdp xfce4 xfce4-goodies
sudo adduser xrdp ssl-cert
echo xfce4-session > ~/.xsession
sudo systemctl restart xrdp
echo "Connect with an RDP client to $(hostname -I | awk '{print $1}'):3389"

🪤 Traps, in one table

SymptomCause
The RDP session opens a different desktopNo ~/.xsession for that user
Cannot read private key file /etc/xrdp/key.pem in the logxrdp not in ssl-cert: the connection works, without TLS
exec startxfce4 in xrdp.ini “does not work”It never did: the desktop is chosen by ~/.xsession
~/.xsession owned by rootCreated with sudo tee: create it as the user
Port 3389 reachable from the internetUse the SSH tunnel, or ufw allow from <your LAN>

📚 Resources