Remote desktop on a Linux VPS: XFCE, xrdp and VNC

Linux 17 min read

A Linux server does not come with a graphical interface by default: you manage it from the command line, over SSH. If you do need a desktop, you can install a lightweight desktop environment (XFCE) and reach it with remote desktop: with xrdp over the Windows Remote Desktop Protocol (RDP), or with VNC. This article covers the installation, secure access and common errors, using your own KVM VPS as the example.

We tested the steps in November 2026 on Ubuntu 24.04, Debian 13.7, AlmaLinux 9.9 and AlmaLinux 10.2; the clients were FreeRDP 3 (xfreerdp3) and TigerVNC Viewer, connecting to the AlmaLinux servers from another Linux machine over an SSH tunnel. On Rocky Linux the steps are the same as on AlmaLinux (it uses the same EPEL packages), but we have not tested them there or on CloudLinux. For a comparison of the options (xrdp, X2Go, VNC) and tips on speed, see the post Setting up a remote desktop on a Linux VPS.

When is it worth it, and when is SSH enough?

Most server tasks need no graphical interface: installing packages, configuring a web server or database, reading logs and copying files are all faster over SSH, and don’t need hundreds of megabytes of memory. For moving files there are SFTP clients, and a web interface running on the server (for example an admin page reachable only internally) can be opened in your own browser through an SSH tunnel. SSH is covered in How do I connect to my VPS via SSH?

Remote desktop is a good choice if you:

  • want to run a program that only has a graphical interface;
  • want to use a browser on the server, for example in an always-on work environment;
  • want a desktop that is always running, reachable from anywhere and independent of the state of your own computer.

How many resources do you need?

A VPS has no graphics card: the processor draws the image, so a lightweight desktop environment is the right choice. In our test, the installation and a logged-in desktop took this much (without a browser; memory is the “used” column of free -m after the installation and with one logged-in remote session):

System Installed packages On disk Memory, idle Logged in
Ubuntu 24.04 xfce4, xfce4-goodies, xrdp 1.9 GB 390 MB 860 MB
Debian 13 xfce4, xfce4-goodies, xrdp 1.4 GB 180 MB 560 MB
AlmaLinux 9 Xfce group (mandatory packages), xrdp 0.7 GB 490 MB 700 MB
AlmaLinux 10 GNOME, gnome-remote-desktop 1.0 GB 700 MB 1260 MB

An XFCE desktop needs at least 2 GB of RAM, and 4 GB for comfortable work with a browser; for the GNOME desktop of AlmaLinux 10, count on 4 GB. If other services run on the server, add what they need as well. If memory is short, the plan can be upgraded, see: How to upgrade my VPS resources (CPU, RAM, storage)?

Preparation: your own user, not root

Don’t log in to the desktop as root: a browser or any desktop program running as root puts the whole system at risk. Create your own user and give it sudo rights. On Ubuntu and Debian:

sudo adduser teszt
sudo usermod -aG sudo teszt

On AlmaLinux and Rocky Linux:

sudo useradd -m -G wheel teszt
sudo passwd teszt

Replace teszt with your own username. Both xrdp and VNC let you in with this password (or, for VNC, with its separate password), so make it long and unique. In detail: Creating a user and granting sudo privileges on Linux.

Installing XFCE and xrdp on Ubuntu and Debian

sudo apt update
sudo apt install xfce4 xfce4-goodies xrdp

In our test, xrdp 0.9.24 was installed on Ubuntu 24.04 and 0.10.1 on Debian 13; the xrdp service started right after the installation and also starts at boot. Three settings follow.

1. Choosing the desktop. On Ubuntu, the recommended packages of xfce4-goodies also install the GNOME session manager, and xrdp starts that by default, which in our test stopped with the error “Oh no! Something has gone wrong.” So, as your own user (not with sudo), set XFCE as the desktop to start:

echo "xfce4-session" > ~/.xsession

On Debian 13 this was not needed (XFCE is the default there), but it does no harm there either.

2. Encrypted connection (Ubuntu). On Ubuntu 24.04, xrdp cannot read the certificate key, so it accepts connections with the old RDP encryption instead of TLS. In the log (/var/log/xrdp.log) it looks like this:

[WARN ] Cannot accept TLS connections because certificate or private key file is not readable. certificate file: [/etc/xrdp/cert.pem], private key file: [/etc/xrdp/key.pem]

Add the xrdp user to the ssl-cert group and restart the service:

sudo adduser xrdp ssl-cert
sudo systemctl restart xrdp

After that, the log shows a TLS connection: TLS connection established from 127.0.0.1 port 49206: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384. On Debian 13 this step was not needed; the first connection there was already made over TLS.

3. Turning off the local login screen (recommended). The installation also adds the LightDM login screen and sets the system to boot into graphical mode. xrdp does not need it, and a login screen running on the VPS console only takes up memory:

sudo systemctl set-default multi-user.target

After the next reboot LightDM does not start, but xrdp does; in our test, memory usage after the reboot was 390 MB.

Installing XFCE and xrdp on AlmaLinux 9 and Rocky Linux 9

xrdp and XFCE are in the EPEL repository. Enable EPEL and the CRB repository (in detail: Installing the EPEL repository on AlmaLinux):

sudo dnf install epel-release
sudo crb enable

Install only the mandatory packages of the Xfce group, as its default packages include the GDM login screen, which is not needed here. You also need a terminal, xrdp and the X server module (xorgxrdp):

sudo dnf group install --setopt=group_package_types=mandatory Xfce
sudo dnf install xfce4-terminal xrdp xorgxrdp

In our test, the xrdp-0.10.6.1-3.el9, xorgxrdp-0.10.5-1.el9 and xfce4-session-4.18.3-1.el9 packages were installed, together with the xrdp-selinux package, so it also worked with SELinux enabled (Enforcing).

On AlmaLinux, xrdp reads which desktop to start from the ~/.Xclients file; if the file is missing, the connection drops right after login. As your own user:

echo "xfce4-session" > ~/.Xclients
chmod +x ~/.Xclients

Finally, start xrdp and enable it at boot:

sudo systemctl enable --now xrdp

AlmaLinux 10 and Rocky Linux 10: GNOME with remote login

Red Hat Enterprise Linux 10 has dropped the X.org server and the TigerVNC server, so the systems based on it lack them too. At the time of our test, EPEL 10 (including its testing repository) had no xrdp, XFCE or tigervnc-server package. On AlmaLinux 10 the way to go is therefore the GNOME desktop with the built-in GNOME Remote Desktop: it speaks RDP too, so you reach it with the same clients.

sudo dnf install gdm gnome-shell gnome-session-wayland-session gnome-remote-desktop ptyxis nautilus

In our test this installed 320 packages (gnome-shell-49.5, gnome-remote-desktop-49.3); the terminal program on RHEL 10 is Ptyxis, as there is no gnome-terminal package.

Remote login needs a TLS certificate. Create a self-signed one as the gnome-remote-desktop user and give it to the service:

sudo -u gnome-remote-desktop openssl req -new -newkey rsa:4096 -days 720 -nodes -x509 \
  -subj "/CN=vps" \
  -out /var/lib/gnome-remote-desktop/rdp-tls.crt \
  -keyout /var/lib/gnome-remote-desktop/rdp-tls.key
sudo grdctl --system rdp set-tls-key /var/lib/gnome-remote-desktop/rdp-tls.key
sudo grdctl --system rdp set-tls-cert /var/lib/gnome-remote-desktop/rdp-tls.crt

Then set a username and password for the remote connection itself, enable RDP and set the system to boot into graphical mode:

sudo grdctl --system rdp set-credentials rdpkapu 'Hosszu-Kapu-Jelszo'
sudo grdctl --system rdp enable
sudo systemctl enable gnome-remote-desktop.service
sudo systemctl set-default graphical.target
sudo systemctl reboot

rdpkapu and its password are not a Linux user, only the “gate” of the remote connection: you connect with them in the client, then choose your own Linux user on the GNOME login screen that appears in the window and log in with that user’s password. grdctl prints this on every call: Init TPM credentials failed because No TPM device found, using GKeyFile as fallback. This is not an error: the VPS has no TPM chip, so the password is stored in a file.

The reboot cannot be skipped: in our test, when started before it with systemctl enable --now, the service stopped with a timeout every minute and a half (start operation timed out); after a reboot it started without errors. sudo grdctl --system status shows the status:

RDP:
	Status: enabled
	Port: 3389
	Authentication methods: credentials

GNOME Remote Desktop listens on port 3389 on every network address, and cannot be set to accept connections on localhost only. A firewall is therefore a must here (see the next section).

Don’t open port 3389 to the world

Open RDP ports on the internet are scanned constantly, and passwords are tried on them. The secure solution is to keep port 3389 unreachable from outside altogether and to connect over an SSH tunnel instead: the connection then runs through the encrypted SSH channel, and logging in first requires your SSH key or SSH password as well.

Make xrdp listen on localhost only

By default xrdp listens on every address. If you only use it over an SSH tunnel, change the port=3389 line in the [Globals] section of the /etc/xrdp/xrdp.ini file to this:

port=tcp://.:3389

Then restart it (sudo systemctl restart xrdp). To check:

sudo ss -ltnp | grep 3389
LISTEN 0      2          127.0.0.1:3389      0.0.0.0:*    users:(("xrdp",pid=18049,fd=11))

This worked the same way on Ubuntu (xrdp 0.9.24) and AlmaLinux 9 (xrdp 0.10.6). For checking open ports, see Check Open Ports on Linux: ss, lsof and netstat.

Connecting over an SSH tunnel

On your own computer (Linux, macOS, or PowerShell on Windows 10/11), start the tunnel and leave the window open while you work:

ssh -N -L 13389:localhost:3389 teszt@203.0.113.25

-L 13389:localhost:3389 forwards port 13389 of your own computer to port 3389 of the server, and -N means that it opens no shell, only keeps the tunnel up. If SSH runs on a different port on the VPS, add the -p option. In the remote desktop client, then connect to localhost:13389. We don’t use local port 3389 because on Windows it may be taken by the computer’s own Remote Desktop service.

If you use it regularly, you can also define the tunnel in the ~/.ssh/config file (LocalForward 13389 localhost:3389), see: SSH Config File (~/.ssh/config) Explained with Examples.

If you still want to connect directly: only from your own IP address

If an SSH tunnel is not an option, allow port 3389 in the firewall only from your own fixed IP address (203.0.113.10 in the example). On Ubuntu and Debian with ufw:

sudo ufw allow OpenSSH
sudo ufw allow from 203.0.113.10 to any port 3389 proto tcp
sudo ufw enable

On AlmaLinux and Rocky Linux with firewalld:

sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.10" port port="3389" protocol="tcp" accept'
sudo firewall-cmd --reload

In our test, the default zone of firewalld (public) only allowed the ssh, cockpit and dhcpv6-client services, so port 3389 stays closed without a rule. If the server has no firewall yet, How do I set up a firewall on my VPS? walks you through setting one up. In this case, leave the port= line of xrdp at 3389, as it has to be reachable from outside.

Disabling root login in xrdp

By default xrdp lets the root user in as well (AllowRootLogin=true). In the [Security] section of the /etc/xrdp/sesman.ini file, change it to:

AllowRootLogin=false

Then run sudo systemctl restart xrdp. In our test, a root login attempt then ended like this, according to /var/log/xrdp-sesman.log: ROOT login attempted, but root login is disabled.

Connecting from the client

  • Windows: the built-in Remote Desktop Connection (mstsc). In the Computer field, enter localhost:13389 for an SSH tunnel, or the VPS’s IP address for a direct connection.
  • macOS: Microsoft’s free Windows App from the Mac App Store.
  • Linux: the Remmina client (both RDP and VNC), or FreeRDP from the command line: xfreerdp3 /v:localhost:13389 /u:teszt /size:1600x900.

The client settings (certificate warning, resolution, clipboard, shared folders) are covered in detail in Connecting to a Windows VPS with Remote Desktop (RDP); they work the same way with a Linux server. xrdp and GNOME Remote Desktop use a self-signed certificate, so on the first connection the client asks whether you trust it.

VNC (TigerVNC) as an alternative, only over an SSH tunnel

VNC is another remote desktop protocol (RFB), also with many clients (TigerVNC Viewer, Remmina). The protocol itself does not encrypt: with the basic VncAuth authentication, the password and the screen are sent unencrypted. The TigerVNC server handles this differently on the two systems:

  • On Ubuntu 24.04 (TigerVNC 1.13.1) it listens on localhost only by default, and only offers unencrypted VncAuth (according to the client’s log: Choosing security type VncAuth(2)).
  • On AlmaLinux 9 (TigerVNC 1.16.2) it also offers TLS without authentication (Choosing security type TLSVnc (258)), which protects against eavesdropping but does not verify that you are really connecting to your own server.

So on both systems, run VNC on localhost only and reach it over an SSH tunnel. On top of that, only the first 8 characters of a VNC password count: vncpasswd silently cuts off a longer one. There is no TigerVNC server on AlmaLinux 10 (see above).

On Ubuntu and Debian (tested on Ubuntu 24.04):

sudo apt install tigervnc-standalone-server
echo ":1=teszt" | sudo tee -a /etc/tigervnc/vncserver.users

As your own user, set the VNC password (answer n to the “view-only password” question), then start the service:

vncpasswd
sudo systemctl enable --now tigervncserver@:1

Here too, ~/.xsession decides which desktop starts, so on Ubuntu you need the same xfce4-session line as for xrdp.

On AlmaLinux 9 and Rocky Linux 9:

sudo dnf install tigervnc-server
echo ":1=teszt" | sudo tee -a /etc/tigervnc/vncserver.users
sudo sed -i 's/^session=gnome/session=xfce/' /etc/tigervnc/vncserver-config-defaults
echo "localhost" | sudo tee -a /etc/tigervnc/vncserver-config-defaults

Out of the box, the /etc/tigervnc/vncserver-config-defaults file contains the line session=gnome; without GNOME the session would not start, so it has to be changed to XFCE. The localhost line limits listening to localhost. Then, as your own user, run vncpasswd, followed by:

sudo systemctl enable --now vncserver@:1
sudo ss -ltnp | grep 5901
LISTEN 0      5          127.0.0.1:5901      0.0.0.0:*    users:(("Xvnc",pid=7520,fd=9))
LISTEN 0      5              [::1]:5901         [::]:*    users:(("Xvnc",pid=7520,fd=10))

Display :1 uses port 5901 (5900 + the display number). On your own computer:

ssh -N -L 5901:localhost:5901 teszt@203.0.113.25

Then connect to localhost:5901 in the VNC client. The default resolution is 1024×768; for a larger one on AlmaLinux, add a geometry=1600x900 line to the vncserver-config-defaults file.

A user can run only one XFCE session at a time (in our test a second session stopped immediately), so don’t be logged in with the same user over both xrdp and VNC at the same time. Use a separate user for each, or only one of the two.

Keyboard layout

The RDP client sends its own keyboard layout, but not every xrdp version picks it up:

  • AlmaLinux 9 (EPEL, xrdp 0.10.6): the Hungarian layout we tested (0x040E) is in the xrdp layout table, and in our test the session started with the Hungarian layout on its own.
  • Ubuntu 24.04 and Debian 13: the Hungarian layout is missing from the xrdp layout table, so the session started with the US (us) layout. In our test, adding a Hungarian line to the /etc/xrdp/xrdp_keyboard.ini file did not help either (according to the log, xrdp picked it up, but the session still stayed on us).

If your layout does not come through, set it in XFCE: Settings › Keyboard › Layout, turn off Use system defaults and add your own layout (for example English (UK)). The same from the command line, in a terminal opened on the remote desktop (gb is the UK layout; use your own layout code, such as us or de):

xfconf-query -c keyboard-layout -p /Default/XkbDisable -n -t bool -s false
xfconf-query -c keyboard-layout -p /Default/XkbLayout -n -t string -s gb

The setting takes effect immediately and is kept at the next login. To check, run setxkbmap -query: the layout: line shows the layout you set (in our test with the Hungarian layout, hu). On the GNOME desktop of AlmaLinux 10, set it under Settings › Keyboard › Input Sources, or with this command:

gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'gb')]"

Common errors

  • “Oh no! Something has gone wrong.” after login (Ubuntu): xrdp starts the GNOME session instead of XFCE. Create the ~/.xsession file (echo "xfce4-session" > ~/.xsession), log out and connect again.
  • The connection drops right after login (AlmaLinux 9): the ~/.Xclients file is missing or not executable. In this case /var/log/xrdp-sesman.log says: Window manager (pid 4335, display 10) exited quickly (0 secs). This could indicate a window manager config problem.
  • Black or blank screen, or an immediate disconnect, although it worked before: the same user is already logged in to another graphical session (an old xrdp session, over VNC or on the console). In our test on Ubuntu, this happened after restarting xrdp: the old session kept running, and the new one stopped with the same “exited quickly” message. Log out of the other session, or end all sessions of the user: sudo loginctl terminate-user teszt (this also closes that user’s SSH connections).
  • “Non-TLS connection established” in the log (Ubuntu): xrdp cannot read the certificate key, so the connection uses the weaker RDP encryption. Fix: sudo adduser xrdp ssl-cert, then restart xrdp.
  • “Authentication is required to create a color managed device” pop-up: the colour management service (colord) asks for a password from the remote session. It did not appear in our tests (Ubuntu 24.04 XFCE, AlmaLinux 10 GNOME), because the system treated the remote session as active; on older systems it is common. If it comes up, create a /etc/polkit-1/rules.d/45-colord.rules file with this content (on AlmaLinux, use the wheel group instead of sudo):

    polkit.addRule(function(action, subject) {
        if (action.id.indexOf("org.freedesktop.color-manager.") == 0 &&
            subject.isInGroup("sudo")) {
            return polkit.Result.YES;
        }
    });
    

    Then run sudo systemctl restart polkit. The rule lets users with sudo rights manage colour profiles without a password.

  • AlmaLinux 10 GNOME Remote Desktop does not start (“start operation timed out”): restart the server after the installation; the service then starts normally.
  • Cannot connect: check that the service is running (systemctl status xrdp), that the SSH tunnel is up, and that you connect to the local port (localhost:13389) in the client. For a direct connection, check that the firewall allows your own IP address and that your IP address has not changed.

The logs almost always reveal the cause: /var/log/xrdp.log, /var/log/xrdp-sesman.log and the user’s own ~/.xsession-errors file; for the GNOME Remote Desktop log, run sudo journalctl -u gnome-remote-desktop. More: Reading log files on Linux: journalctl and the /var/log directory.

Back: Linux articles (77)