You spin up a fresh Ubuntu 24.04 server, install a desktop, connect with Remote Desktop and get one of three things: a black screen, a session that closes the second you log in, or a desktop where Firefox simply refuses to open.
This guide gets you a light, usable remote desktop on a cloud server and fixes those three problems on purpose, instead of leaving you to search for them later. It uses XFCE because it is fast over RDP, and xrdp because it works with the Remote Desktop client already built into Windows, plus Microsoft's free app on macOS, iOS and Android.
Everything here was written for Ubuntu 24.04 LTS on a KVM virtual server. It also works on Debian 12 with small changes.
When a desktop on a server makes sense
Most servers should stay headless. A desktop is worth it when you need a real browser on a remote network (testing geo-targeted pages, logging into dashboards from a fixed IP), a GUI-only tool, a long-running app you want to check on visually, or a remote workspace you can reach from any device.
Sizing matters more than people expect. The desktop itself is small, but a modern browser is not. Plan for 2 GB of RAM as a practical minimum for one user with a browser, and 4 GB if you keep several tabs open or more than one person connects. One vCPU works, two feels much smoother.
Step 1: create a normal user for the desktop
Do not run your desktop session as root. Several desktop components refuse to start or behave oddly as root, and a browser running as root is a bad idea anyway.
sudo adduser deskuser sudo usermod -aG sudo deskuser Use this account for everything below that says "as your desktop user".
Step 2: install XFCE without the extras you do not need
sudo apt update sudo apt install -y xfce4 xfce4-goodies dbus-x11 Two notes on that line:
- dbus-x11 is the piece people forget. Without it, XFCE often starts with an error about not reaching the settings server, and panels or settings go missing.
- When the installer asks you to pick a display manager, choose lightdm or just accept the default. xrdp does not use it, so the choice does not matter for remote sessions.
Step 3: install xrdp and point it at XFCE
sudo apt install -y xrdp sudo adduser xrdp ssl-cert The ssl-cert group gives xrdp read access to the system certificate it uses to encrypt the connection. Skip it and you can get a login that fails right after you type your password.
Now tell xrdp which desktop to start. As your desktop user:
echo "xfce4-session" > ~/.xsession chmod +x ~/.xsession Then restart the service and make sure it is listening:
sudo systemctl restart xrdp sudo ss -ltnp | grep 3389 You should see xrdp on port 3389.
Step 4: do not open port 3389 to the internet
This is the step most tutorials get wrong. They tell you to run ufw allow 3389 and move on. Port 3389 is one of the most scanned ports on the internet, and a desktop login exposed to the world will see password guessing within hours.
The better pattern is to keep 3389 closed and reach it through SSH, which you already have.
On the server, make sure only SSH is allowed in:
sudo ufw allow OpenSSH sudo ufw enable sudo ufw status Do not add a rule for 3389.
On your own computer, open a tunnel. Using local port 13389 avoids clashing with a Remote Desktop service that may already run on your own machine:
ssh -L 13389:localhost:3389 deskuser@YOUR_SERVER_IP Leave that window open, then connect your Remote Desktop client to:
localhost:13389 Log in with your desktop user. Your whole session now travels inside SSH, and nothing new is exposed. If you use SSH keys, you also get key-based protection in front of the desktop for free.
On Windows, the same ssh command works in PowerShell or Windows Terminal, since OpenSSH is built in.
Step 5: the Firefox snap trap, and how to get a browser that works
Here is the one that wastes the most time. On Ubuntu 24.04, sudo apt install firefox does not install a normal package. It installs a small transitional package that pulls in the Firefox snap.
Inside an xrdp session, the snap version often fails to start, sometimes with an error mentioning a "snap cgroup", sometimes with nothing at all except a window that never appears. The cause is how snap confinement tracks the session, not anything you did wrong.
The clean fix is to use Mozilla's own APT repository, which gives you a regular .deb package that updates through apt.
Remove the snap if it is installed:
sudo snap remove firefox Add Mozilla's signing key and repository:
sudo install -d -m 0755 /etc/apt/keyrings wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | sudo tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" | sudo tee /etc/apt/sources.list.d/mozilla.list > /dev/null Tell apt to prefer Mozilla's package over Ubuntu's snap wrapper:
echo ' Package: * Pin: origin packages.mozilla.org Pin-Priority: 1000 ' | sudo tee /etc/apt/preferences.d/mozilla Install it:
sudo apt update sudo apt install -y firefox Check you got the real package and not the snap again:
apt policy firefox The installed version should come from packages.mozilla.org. Firefox now opens normally inside your remote session. The same idea applies to Chromium, which is also a snap on Ubuntu; Google Chrome's own .deb is the simplest alternative there.
Step 6: make it feel fast
RDP sends screen changes over the network, so anything that animates or redraws a lot makes the session feel slow. Three changes make a visible difference.
Turn off the window compositor. In XFCE, open Settings, then Window Manager Tweaks, then the Compositor tab, and untick "Enable display compositing". Or from a terminal inside the session:
xfconf-query -c xfwm4 -p /general/use_compositing -s false Use a plain background. A solid color compresses far better than a photo.
Match your client settings to your connection. In the Windows Remote Desktop client, under Show Options, then Experience, pick your real connection speed instead of "Detect automatically" if the session feels laggy, and lower the color depth on slow links.
Step 7: stop forgotten sessions from eating memory
By default, if you close the Remote Desktop window instead of logging out, your session keeps running on the server, browser and all. Do that a few times and you run out of RAM.
You can tell xrdp to clean up sessions that stay disconnected. Edit /etc/xrdp/sesman.ini and, in the [Sessions] section, set:
KillDisconnected=true DisconnectedTimeLimit=3600 That ends a session one hour after it is disconnected. Restart xrdp afterwards:
sudo systemctl restart xrdp If you prefer to keep long-running apps alive between connections, leave this off and simply log out properly when you are done.
Troubleshooting the three classic failures
Black screen after login. Check ~/.xsession exists in the home folder of the user you log in as, contains xfce4-session, and is executable. Then look at the session log:
cat ~/.xsession-errors Session closes immediately after login. This usually means the desktop failed to start. Confirm dbus-x11 is installed, and check the xrdp logs:
sudo journalctl -u xrdp -u xrdp-sesman --since "10 min ago" A related cause is a desktop session for the same user already running elsewhere. Log that session out, or use a separate user for remote access.
Repeated "Authentication required" pop-ups. On some installs, a color management service asks for a password every time you log in over RDP. You can allow it for normal users with a small polkit rule. Create /etc/polkit-1/rules.d/45-allow-colord.rules:
polkit.addRule(function(action, subject) { if (action.id.indexOf("org.freedesktop.color-manager.") == 0 && subject.isInGroup("users")) { return polkit.Result.YES; } }); Then make sure your desktop user is in the users group (groups deskuser) and log in again.
Quick checklist
- Desktop runs as a normal user, not root
-
xfce4,dbus-x11andxrdpinstalled, xrdp inssl-cert -
~/.xsessionstartsxfce4-session - Port 3389 closed, access through an SSH tunnel
- Firefox from Mozilla's APT repo, not the snap
- Compositor off, plain background
- Disconnected sessions cleaned up, or you log out properly
Going further
If you are on AlmaLinux or Rocky Linux instead of Ubuntu, or you would rather use VNC than RDP, I keep a shorter reference that covers both, along with security habits for desktops on servers: install XFCE on a Linux VPS with xrdp or VNC.
With these steps you get a remote desktop that starts every time, opens a browser on the first try, stays responsive on an ordinary connection and does not put a login screen on the open internet. If you hit a problem that is not covered here, leave a comment with your Ubuntu version and the last lines of ~/.xsession-errors, and I will take a look.
