Operating System Ubuntu

How to Install a VNC Desktop (Xfce + TigerVNC) on Ubuntu 26.04 LTS

Install Xfce and TigerVNC on an Ubuntu 26.04 server, start the desktop as a systemd service and reach it from any VNC viewer over an SSH tunnel.

This guide puts a lightweight graphical desktop on an Ubuntu 26.04 LTS server and makes it reachable from your own computer with a VNC viewer. The desktop is Xfce, the VNC server is TigerVNC, the session starts at boot as a systemd service, and the connection travels through an SSH tunnel so no VNC port is exposed to the internet. Notes for Ubuntu 24.04 LTS are included where it differs.

Ubuntu 14.04 is long out of support, and the TightVNC 1.3 server that older tutorials pair with LXDE is an ageing X server. TigerVNC is its maintained successor and speaks the same protocol, so the viewer you already use keeps working.

Requirements

  • Ubuntu 26.04 LTS (or 24.04 LTS) with a non-root user that has sudo rights. The examples use deploy.
  • 1 GB of RAM is workable for Xfce; 2 GB is more comfortable once a browser is open.
  • SSH access to the server, and a VNC viewer on your computer (TigerVNC viewer, Remmina, RealVNC viewer or similar).

Install the Xfce desktop

Update the package lists and install Xfce. Both packages are in the universe repository, which is enabled by default on Ubuntu Server.

sudo apt update
sudo apt install xfce4 xfce4-goodies

xfce4 is the core desktop (panel, window manager, file manager, settings); xfce4-goodies adds the terminal, a text editor and panel plugins. Neither pulls in a graphical login manager, which is what you want here: the server has no monitor, and VNC starts the session itself. If the installer asks you to pick a display manager because another desktop package brought one in, the choice does not affect VNC.

Install TigerVNC

sudo apt install tigervnc-standalone-server tigervnc-tools

tigervnc-standalone-server provides the tigervncserver command, the virtual X server Xtigervnc and a systemd template unit. tigervnc-tools provides tigervncpasswd.

Set the VNC password and select Xfce

Run these commands as the user who will own the desktop, not as root:

mkdir -p ~/.config/tigervnc
tigervncpasswd

Enter a password and answer n when asked about a view-only password. Classic VNC authentication only uses the first eight characters, which is one reason this guide keeps the port closed. The password is stored in ~/.config/tigervnc/passwd.

Tell TigerVNC which desktop session to start by creating its per-user configuration file:

nano ~/.config/tigervnc/config.pl
$session = "xfce";
$geometry = "1600x900";

$session must match a file in /usr/share/xsessions; the Xfce package installs xfce.desktop there. $geometry sets the size of the virtual screen (the default is 1920x1200).

Start the desktop once to test it

Start a session on display :1, which corresponds to TCP port 5901:

tigervncserver :1

Check that it is running:

tigervncserver -list

With password authentication only, TigerVNC listens on the loopback interface by default, so the port is not reachable from outside. You can confirm that with:

ss -ltnp | grep 5901

The listening address should be 127.0.0.1 (and [::1]). Stop the test session before setting up the service:

tigervncserver -kill :1

Run the desktop as a systemd service

The package ships the template unit tigervncserver@.service. It starts a session for whichever user is assigned to the display number in /etc/tigervnc/vncserver.users. Assign display :1 to your user:

echo ':1=deploy' | sudo tee -a /etc/tigervnc/vncserver.users

Enable and start the unit for that display:

sudo systemctl enable --now tigervncserver@:1.service
systemctl status tigervncserver@:1.service

The Xfce session now starts at boot and keeps running, with your open windows, when you close the viewer.

Connect through an SSH tunnel

On your own computer, forward local port 5901 to the same port on the server:

ssh -L 5901:localhost:5901 deploy@203.0.113.10

Keep that SSH session open, start your VNC viewer and connect to:

localhost:5901

Some viewers write this as localhost:1. Enter the VNC password and the Xfce desktop appears, already logged in as deploy. On Windows, PuTTY does the same under Connection, SSH, Tunnels (source port 5901, destination localhost:5901). Because everything goes through SSH, port 5901 needs no firewall rule; only SSH has to be reachable.

Troubleshooting

  • Grey screen or the session ends at once: read the newest log file in ~/.local/state/tigervnc/ (or ~/.config/tigervnc/). Check the spelling of $session and that /usr/share/xsessions/xfce.desktop exists.
  • The service does not start: the user must have set a password with tigervncpasswd, and the display number in vncserver.users must match the one in the unit name. journalctl -u tigervncserver@:1.service shows the reason.
  • Connection refused in the viewer: the SSH tunnel is not open, or the session runs on another display. tigervncserver -list shows the display and port in use.
  • Screen locker asks for a password you never set: the desktop runs as your Linux user, so the lock screen wants that account's password, not the VNC one. Disable the screensaver lock in the Xfce settings if the account has no password.
  • Ubuntu 24.04: the package names and the service are the same, but its TigerVNC 1.13 keeps the password, config.pl and logs in ~/.vnc instead of ~/.config/tigervnc. Use that directory in the commands above.

All options are documented in the tigervncserver manual page.

Frequently asked questions

Why Xfce instead of the default Ubuntu desktop?

Ubuntu's GNOME desktop is built around Wayland and hardware-accelerated graphics, neither of which a virtual VNC display provides. Xfce runs as a plain X11 session, uses a few hundred megabytes of memory and redraws quickly over a remote link.

Can several users have their own desktop?

Yes. Add one line per user to /etc/tigervnc/vncserver.users with a different display number (:2=lisa), have each user run tigervncpasswd, and enable tigervncserver@:2.service. Display :2 listens on port 5902.

Why not simply open port 5901 in the firewall?

VNC passwords are short and VNC ports are scanned constantly. The SSH tunnel adds key-based authentication and encryption with no extra software. If you must listen on the network, use TigerVNC's TLS security types and restrict the source address in the firewall.

Does this share the screen of a physical monitor?

No. tigervncserver creates a virtual display that exists only in memory, which is the right tool for a VPS. Sharing an existing local X session is done by a different program, x0tigervncserver.

Share story:

Continue reading other guides on How VPS.