Some tasks are easier with a graphical desktop: running a browser, a GUI tool or a desktop application on a remote machine. XFCE is light enough for a small server, and TigerVNC lets you see it from your own computer. This guide sets it up on a VPS Linux Infrawire so that the VNC port is never exposed to the Internet: you reach it only through an SSH tunnel.
📋 Prerequisites
- A VPS running Ubuntu 24.04 or Debian 12 with root SSH access (from your customer area you will find the VPS IP and the root password).
- At least 2 GB of RAM for a comfortable desktop.
- An SSH client on your computer and a VNC viewer (RealVNC Viewer or TigerVNC Viewer).
- A regular user account: do not run the desktop as root.
📦 Install XFCE and TigerVNC
Update the system, then install the desktop and the server. dbus-x11 avoids a frequent grey-screen problem.
Bashapt update && apt upgrade -y apt install -y xfce4 xfce4-goodies tigervnc-standalone-server tigervnc-common dbus-x11
Create a dedicated user if you do not have one yet:
Bashadduser USER usermod -aG sudo USER
🔑 Set the VNC password and the session
Switch to that user and set the VNC password (8 characters are significant at most):
Bashsu - USER vncpasswd
Answer n to the read-only password question. Then tell TigerVNC to start XFCE:
Bashmkdir -p ~/.vnc cat > ~/.vnc/xstartup <<'EOF' #!/bin/sh unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS exec startxfce4 EOF chmod +x ~/.vnc/xstartup
Test it by hand, listening on localhost only:
Bashvncserver :1 -localhost yes -geometry 1920x1080 -depth 24 vncserver -list vncserver -kill :1
⚙️ Start it automatically with systemd
Back as root, create a unit that runs the session for your user. Display :1 maps to TCP port 5901.
INI1# /etc/systemd/system/vncserver@.service 2[Unit] 3Description=TigerVNC server on display %i 4After=network.target 5 6[Service] 7Type=forking 8User=USER 9Group=USER 10WorkingDirectory=/home/USER 11PIDFile=/home/USER/.vnc/%H:%i.pid 12ExecStartPre=-/usr/bin/vncserver -kill :%i 13ExecStart=/usr/bin/vncserver :%i -localhost yes -geometry 1920x1080 -depth 24 14ExecStop=/usr/bin/vncserver -kill :%i 15 16[Install] 17WantedBy=multi-user.target
Bashsystemctl daemon-reload systemctl enable --now vncserver@1.service systemctl status vncserver@1.service
For a second user, copy the unit under another name with that user and display :2 (port 5902).
🔒 Connect through an SSH tunnel
The -localhost yes option makes VNC listen on 127.0.0.1 only, so nothing is reachable from outside. From your own computer, open a tunnel:
Bashssh -N -L 5901:localhost:5901 USER@VPS_IP
Leave that window open. In your VNC viewer, connect to localhost:5901 and enter the VNC password. The same command works in Windows PowerShell and macOS Terminal. Do not open port 5901 in any firewall.
✅ Verification
On the VPS, confirm that VNC listens on the loopback address only:
Bashss -tlnp | grep 5901 systemctl is-active vncserver@1.service
You should see 127.0.0.1:5901 and not 0.0.0.0:5901. From your computer, the viewer should show the XFCE desktop after the tunnel is up.
🛠️ Troubleshooting
Grey screen or no desktop. Check that ~/.vnc/xstartup is executable, that dbus-x11 is installed and read the log with cat ~/.vnc/*.log. A missing exec startxfce4 line is the most common cause.
"A VNC server is already running as :1". A stale lock remains. Run vncserver -kill :1, then remove /tmp/.X1-lock and /tmp/.X11-unix/X1 if they persist, and restart the service.
The tunnel refuses the connection. The service is probably stopped: check systemctl status vncserver@1.service. Also make sure the local port 5901 is not already used on your computer, or pick another one such as -L 5999:localhost:5901.
🎉 Your VPS now offers a private XFCE desktop, reachable only through your SSH tunnel.