How to Install and Configure TigerVNC on Ubuntu 22.04 and 24.04

Virtual Network Computing (VNC) is a graphical remote-access protocol that sends framebuffer updates to a local display while transmitting keyboard and mouse input back to the remote system. This makes it suitable for administrators who need to work with files, web browsers, desktop applications, and other graphical utilities without accessing the machine directly.

This tutorial covers Ubuntu 22.04 and 24.04 LTS systems. You will follow a standard command-line installation using TigerVNC packages from the Ubuntu repositories, combine TigerVNC with Xfce for lightweight graphical sessions, and optionally configure GNOME when GNOME over Xorg is preferred. TigerVNC originated as a fork of the historic TightVNC codebase and continues to receive fixes through Ubuntu, making it the modern replacement for TightVNC while retaining familiar vncserver workflows. You will create a VNC password with vncpasswd, use display :1, protect the connection through an SSH tunnel, and configure a systemd unit so the VNC server can be managed and restarted consistently.

VNC differs from Remote Desktop Protocol (RDP) because VNC primarily transports framebuffer data instead of relying on the Windows-oriented negotiation mechanisms commonly associated with RDP clients. SSH X forwarding transports individual X11 applications over SSH, whereas VNC provides a complete desktop session that remains available even after the client disconnects. VNC is appropriate when you require a dedicated remote desktop and can work with rectangle-based compression. SSH X forwarding is more appropriate when only a small number of graphical applications are required and X11 security is already trusted within the network.

Throughout this tutorial, TigerVNC remains bound to 127.0.0.1. Connections are made through SSH port forwarding instead of exposing TCP port 5901 directly.

Key Takeaways

  • TigerVNC is the recommended VNC server for Ubuntu 22.04 and Ubuntu 24.04. It is available from the default repositories, receives upstream security fixes, and replaces the older TightVNC packages found in legacy tutorials.
  • VNC traffic is not encrypted by default. Bind TigerVNC to 127.0.0.1 with -localhost yes and access it through an SSH tunnel instead of exposing port 5901 directly.
  • Wayland is incompatible with this TigerVNC setup. On Ubuntu 22.04 or 24.04 systems using GDM3, configure WaylandEnable=false in /etc/gdm3/custom.conf before setting up VNC. Headless servers without GDM3 do not require this change.
  • A VNC display number corresponds to TCP port 5900 plus the display number. Display :1 therefore uses port 5901, display :2 uses 5902, and the same pattern continues for additional displays.
  • A templated systemd service named vncserver@.service provides automatic startup and regular systemctl management. The value after @ represents the display number rather than the username.

Prerequisites

To complete this tutorial, you need:

  • An Ubuntu 22.04 or Ubuntu 24.04 server or virtual machine with sudo privileges, a non-root user account, and UFW configured. Complete the standard initial Ubuntu server configuration first if this has not already been done.
  • SSH access to the server. For additional security, SSH key-based authentication can also be configured.
  • A local computer with TigerVNC Viewer, RealVNC Viewer, Remmina, or another compatible VNC client that can connect after the SSH tunnel has been established. macOS Screen Sharing can also connect through the forwarded localhost port.

Choosing a VNC Server for Ubuntu

Select the VNC server according to the type of desktop that needs to be provided. Virtual desktop sessions are well suited to headless and cloud-hosted servers, while display-mirroring solutions are generally more appropriate for physical workstations.

TigerVNC (Recommended)

TigerVNC is provided through the Ubuntu repositories as tigervnc-standalone-server and tigervnc-common, and it follows upstream security maintenance. Combining it with XFCE is a practical choice for headless systems where low idle memory usage is important.

TightVNC

TightVNC instructions can still be found in older documentation, but TigerVNC has effectively replaced that codebase for current Ubuntu installations. TigerVNC should normally be preferred unless a specific requirement demands compatibility with legacy TightVNC documentation.

RealVNC

RealVNC is aimed at environments that require managed cloud connectivity and enterprise-oriented policy features. Vendor-provided .deb packages can be installed when those capabilities are required; otherwise, TigerVNC is suitable when packages from the operating-system repositories are preferred.

x11vnc

x11vnc connects to an existing Xorg display instead of creating a new Xvnc framebuffer. It is useful when users need to share or collaborate on an existing physical console, rather than when a new virtual desktop must be created on a headless server.

Comparison of Common VNC Servers

VNC Server Ubuntu 22.04 Support Ubuntu 24.04 Support Wayland Support Authentication License Maintenance Status Notes
TigerVNC Yes (default repositories) Yes (default repositories) No (Xorg only) VNC password, X.509 GPL-2.0 Active Recommended for headless servers
TightVNC Yes (universe, upstream unmaintained) Yes (universe, upstream unmaintained) No (Xorg only) VNC password GPL-2.0 Stale (last upstream release 2009) Still functional, but without current upstream security patches
x11vnc Yes (default repositories) Yes (default repositories) No (Xorg only) VNC password, optional SSL GPL-2.0 Limited Requires an existing Xorg session and is unsuitable for typical headless deployments
RealVNC Yes (manual .deb) Yes (manual .deb) Partial (direct mode on Xorg; cloud relay mode available) VNC password, RealVNC account Commercial (free personal tier) Active Cloud relay requires an account; direct mode can operate without one

Note: If you previously used an Ubuntu 20.04 version of this procedure, the following instructions replace TightVNC with TigerVNC and apply to both Ubuntu 22.04 and Ubuntu 24.04. Older Ubuntu 20.04 instructions remain relevant only as a legacy reference.

Step 1 — Installing the Desktop Environment

This step installs the graphical environment that the VNC session will start. Xfce keeps CPU and memory requirements comparatively low, helping XFCE sessions remain responsive on smaller servers and virtual machines.

Update the package indexes:


Hit:1 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:2 http://archive.ubuntu.com/ubuntu jammy InRelease
Reading package lists... Done

The codename displayed in the package output depends on the installed Ubuntu release. Ubuntu 22.04 uses jammy, while Ubuntu 24.04 uses noble. Either result is expected for the corresponding release.

Install Xfce together with its additional utilities:


sudo apt install xfce4 xfce4-goodies


Reading package lists... Done
Building dependency tree... Done
The following NEW packages will be installed:
  xfce4 xfce4-goodies
0 upgraded, 2 newly installed, 0 to remove, 0 not upgraded.
Need to get 12.4 MB of archives.
After this operation, 45.2 MB of additional disk space will be used.
Do you want to continue? [Y/n]

If the installer asks you to choose a default display manager, either available option is acceptable on a headless server where Xfce will only be launched through VNC.

For a GNOME-based configuration, you can instead install ubuntu-desktop or gnome-session, provided that the higher memory requirements and the Xorg requirement described in Step 2 are acceptable.

Step 2 — Handling Wayland on Ubuntu 22.04 and 24.04

Ubuntu 22.04 and Ubuntu 24.04 normally use Wayland when GNOME and GDM3 are installed. TigerVNC, however, creates virtual Xorg displays and cannot share the Wayland session used by this configuration. This step configures GDM3 to use Xorg so that a local GNOME desktop and TigerVNC rely on the same display protocol, helping avoid blank displays when graphical problems are diagnosed directly on the machine.

First, determine whether GDM3 is currently active:


If the result is inactive or Unit gdm3.service could not be found, GDM3 is not running on the system. In that case, skip the remainder of this step and continue with Step 3.

Open the GDM configuration file:

sudo nano /etc/gdm3/custom.conf

Inside the [daemon] section, make sure the following setting is present:

/etc/gdm3/custom.conf

Restart the system to apply the configuration:


Connection to your_server_ip closed by remote host.

After the server becomes available again, sign in through a physical or serial console if one is available. Open a terminal and verify which session type is active:


Note: Skip this step when Ubuntu Server is installed without GDM and TigerVNC virtual sessions are the only graphical sessions being used. Keep this configuration when gdm3 is installed and GNOME also runs locally on the same virtual machine or server.

Step 3 — Installing TigerVNC Server

The same installation command can be used on both Ubuntu 22.04 and Ubuntu 24.04. Ubuntu 22.04 provides TigerVNC 1.12.x, while Ubuntu 24.04 provides TigerVNC 1.13.x.


sudo apt install tigervnc-standalone-server tigervnc-common


Reading package lists... Done
Building dependency tree... Done
The following NEW packages will be installed:
  tigervnc-common tigervnc-standalone-server
0 upgraded, 2 newly installed, 0 to remove, 0 not upgraded.
Need to get 1,284 kB of archives.
After this operation, 4,980 kB of additional disk space will be used.
Do you want to continue? [Y/n]

Display the installed build information:

On Ubuntu 22.04, the output is expected to resemble the following. Ubuntu 24.04 displays a 1.13.x release with a newer build date:

TigerVNC Server version 1.12.0, built Apr  8 2022 00:00:00
Copyright (C) 1999-2022 TigerVNC Team and many others (see README.rst)
See https://www.tigervnc.org for information on TigerVNC.
Underlying X server release 12101004, The X.Org Foundation

The exact version information can change when Ubuntu publishes security rebuilds. After a successful installation, however, the command should display a TigerVNC version banner.

Step 4 — Configuring the VNC Server

This step configures the authentication credentials and startup scripts required to launch the graphical desktop reliably for each VNC display.

Setting the VNC Password

Start the interactive password utility:


Password:
Verify:
Would you like to enter a view-only password (y/n)? n

TigerVNC saves the password as an obfuscated byte sequence in ~/.vnc/passwd. The protocol uses only the first eight characters of a VNC password regardless of the number of characters entered, so choose a unique password instead of reusing the password for the system account.

Creating ~/.vnc/xstartup

Before editing the startup configuration, stop any existing session using display :1:


Killing Xvnc process ID 17555

If the command instead reports Can't find, no matching VNC session was running, so you can continue normally.

XFCE Startup Script

Open the VNC startup file:

Add the following configuration:

~/.vnc/xstartup

#!/bin/bash
xrdb $HOME/.Xresources 2>/dev/null
startxfce4 &

GNOME Startup Script (Xorg Only)

For a GNOME session, open the same startup file:

Use the following configuration:

~/.vnc/xstartup

#!/bin/bash
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec dbus-run-session -- gnome-session

GNOME requires more memory than Xfce, so monitor available memory and swap space when using this desktop environment.

Setting Execute Permission

Make the startup script executable:

A successful chmod command does not display any output. Confirm the resulting permissions with ls -la ~/.vnc/xstartup.


-rwxr-xr-x 1 user user 60 May  3 14:00 /home/user/.vnc/xstartup

Step 5 — Starting and Testing the VNC Server

This step confirms that TigerVNC starts correctly and listens for connections before automatic startup is configured.

Start display :1. This display maps to TCP port 5901 because VNC uses port 5900 plus the display number:


vncserver :1 -geometry 1920x1080 -depth 24 -localhost yes


New 'server.example.com:1 (user)' desktop is server.example.com:1

Starting applications specified in /home/user/.vnc/xstartup
Log file is /home/user/.vnc/server.example.com:1.log

Display the currently active VNC sessions:


TigerVNC server sessions:

X DISPLAY #     PROCESS ID
:1              18442

Verify that the service is listening only on the loopback address:


LISTEN 0      5            127.0.0.1:5901      0.0.0.0:*    users:(("Xvnc",pid=18442,fd=9))

If ss returns no matching listener, inspect ~/.vnc/*.log. These log files contain information about most problems that prevent TigerVNC from starting successfully.

Step 6 — Creating a Systemd Service for VNC

This step transfers VNC process management to systemd so that TigerVNC can return automatically after reboots and system updates.

Create a templated systemd unit:

sudo nano /etc/systemd/system/vncserver@.service

Insert the following service definition:

/etc/systemd/system/vncserver@.service

[Unit]
Description=TigerVNC for display %i
After=network.target

[Service]
Type=forking
User=user
Group=user
WorkingDirectory=/home/user
PIDFile=/home/user/.vnc/%H:%i.pid

ExecStartPre=-/usr/bin/vncserver -kill :%i >/dev/null 2>&1
ExecStart=/usr/bin/vncserver :%i -geometry 1920x1080 -depth 24 -localhost yes
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target

The ExecStart command must contain -localhost yes rather than only -localhost. This configuration prevents TigerVNC from accepting TCP connections that originate remotely without passing through SSH.

Reload the systemd configuration:

sudo systemctl daemon-reload

Enable the service for display 1:


sudo systemctl enable vncserver@1.service


Created symlink /etc/systemd/system/multi-user.target.wants/vncserver@1.service → /etc/systemd/system/vncserver@.service.

Start the service:

sudo systemctl start vncserver@1.service

A successful start normally produces no output. Use systemctl status immediately afterward to confirm that the service started correctly.

Inspect the current service state:


sudo systemctl status vncserver@1.service


● vncserver@1.service - TigerVNC for display 1
     Loaded: loaded (/etc/systemd/system/vncserver@.service; enabled; vendor preset: enabled)
     Active: active (running) since <day> <date> <time> UTC; 5s ago
    Process: 20111 ExecStartPre=/usr/bin/vncserver -kill :1 (code=exited, status=2)
    Process: 20115 ExecStart=/usr/bin/vncserver :1 -geometry 1920x1080 -depth 24 -localhost yes (code=exited, status=0/SUCCESS)
   Main PID: 20126 (vncserver)
      Tasks: 86 (limit: 4647)
     Memory: 168.2M
        CPU: 4.932s
     CGroup: /system.slice/system-vncserver.slice/vncserver@1.service
             └─20126 /usr/bin/Xvnc :1 -localhost=yes ...

Standard systemctl commands can be used for additional operations when this service-management pattern is extended.

Step 7 — Connecting Securely Through an SSH Tunnel

This step prevents TigerVNC from being exposed directly to the public internet while still allowing a local VNC client to connect to the remote desktop.

Warning: Do not open TCP port 5901 in UFW or any external firewall. Automated systems regularly scan for exposed VNC services. Leave the VNC port closed to external traffic and use SSH forwarding instead. Review your UFW firewall configuration whenever firewall rules need to be changed.

From a Linux or macOS terminal on the local computer, run:

ssh -L 59000:localhost:5901 -C -N -f user@your_server_ip

  • -L 59000:localhost:5901 forwards local port 59000 to localhost:5901 on the remote server after SSH authentication completes.
  • -C activates compression, which can be useful on slower network connections.
  • -N prevents SSH from starting a remote shell, leaving the connection dedicated to port forwarding.
  • -f moves SSH into the background after authentication so the local terminal prompt becomes available again while the tunnel remains active.
  • user@your_server_ip identifies the remote username and server using the normal user@host syntax.

The forwarding path can be represented as follows:

[Laptop]  VNC viewer --> localhost:59000 --> SSH session --> server localhost:5901 --> Xvnc display :1

Windows 10 and newer versions include OpenSSH, so the same SSH command can be entered in PowerShell or Command Prompt without changing the command-line options.

If PuTTY is used on Windows, right-click the PuTTY window title bar and select Change Settings….

Open Connection, expand SSH, choose Tunnels, enter 59000 in Source port, enter localhost:5901 in Destination, select Add, and then select Apply.

Additional SSH tunneling configurations can also be used for reverse forwarding and jump-host arrangements.

Regardless of the VNC client being used, connect the viewer to the local forwarding endpoint, which is localhost:59000 in this example. Do not connect the VNC client directly to the server’s public IP address.

Configure the VNC viewer to connect to localhost:59000, accept a host-key warning if one appears, and authenticate with the VNC password created in Step 4. The default Xfce workspace should then become available.

Files can be managed through Thunar or through any terminal emulator running inside the graphical session.

Closing the VNC viewer disconnects only the client. The graphical session continues running on the server, which means applications and open windows remain available between connections. To reconnect, recreate the SSH tunnel if necessary and open the VNC viewer again. The pkill command below terminates the SSH tunnel itself when it is no longer needed; it does not merely close an individual VNC viewer session.

Because the -f option places SSH in the background, terminate the tunnel by matching its command line rather than by pressing CTRL+C:

pkill -f 'ssh -L 59000:localhost:5901'

If -f is intentionally omitted, the SSH connection remains in the foreground and pressing CTRL+C terminates the tunnel immediately.

Troubleshooting Common VNC Issues on Ubuntu

Begin troubleshooting on the server before assuming that the local network is responsible. Check systemctl status, examine the files in ~/.vnc, and then verify the SSH forwarding configuration on the local computer. Following this order avoids unnecessary firewall changes when the underlying problem is simply that TigerVNC did not start. If ss confirms that the listener exists but connections still fail, also review the UFW and external firewall configuration.

VNC Server Fails to Start

Inspect ~/.vnc/<hostname>:<display>.log after every unsuccessful start. For example, the file might be /home/user/.vnc/server.example.com:1.log. Run vncserver -kill :1, correct any problems in xstartup, and then restart the systemd service.

Black Screen After Connecting

Verify that chmod +x ~/.vnc/xstartup completed successfully and make sure either startxfce4 & or the GNOME dbus-run-session configuration is still present. If the startup file does not have execute permission, TigerVNC can remain on an empty or black framebuffer.

Authentication Failure

Run vncpasswd again, restart the service with sudo systemctl restart vncserver@1.service, establish a new SSH tunnel, and try connecting again.

Connection Refused on Port 5901

Run sudo systemctl status vncserver@1.service, ss -tlnp | grep 5901, and journalctl -u vncserver@1.service -n 50. If the VNC listener appears healthy, confirm that the SSH forwarding connection is still running. The VNC viewer connects to localhost on the computer where the SSH tunnel endpoint exists.

Wayland-Related Display Errors

Open /etc/gdm3/custom.conf again, verify that WaylandEnable=false is configured, reboot the machine, and run echo $XDG_SESSION_TYPE from the console session until the result is x11.

FAQ

How Do I Install and Configure a VNC Server on Ubuntu 24.04?

Ubuntu 24.04 provides the same TigerVNC package names with newer patch releases. Install tigervnc-standalone-server, apply the /etc/gdm3/custom.conf change when GNOME is also running locally, create ~/.vnc/xstartup, and then start the server with vncserver :1 -localhost yes. After installing the package, check vncserver --version because minor version numbers can change between Ubuntu updates.

Which VNC Server Is Best for Ubuntu?

TigerVNC provides a strong combination of Ubuntu repository availability, documentation, and active maintenance for most installations. TightVNC still appears in older guides but receives fewer updates. RealVNC is an option for organizations that require commercial or managed connectivity features. x11vnc is better suited to situations where an existing Xorg console must be mirrored instead of creating an independent virtual framebuffer.

How Do I Know Whether vncserver Is Running on Ubuntu?

Use vncserver -list to display active session IDs. Use ss -tlnp | grep vnc or ss -tlnp | grep 590 to inspect listening ports, and check systemctl status vncserver@1.service when systemd is managing the process. The system journal can also reveal failures that occur immediately after package updates.

Does VNC Work with Wayland on Ubuntu 22.04 or 24.04?

Most TigerVNC configurations of this type continue to depend on X11 behavior even though Xvnc provides a separate framebuffer. Disable Wayland in /etc/gdm3/custom.conf, reboot the machine, and confirm that echo $XDG_SESSION_TYPE returns x11 on interactive GNOME console sessions to prevent conflicting display-session types.

Is There an Open-Source Alternative to RealVNC in the Ubuntu Repositories?

Yes. TigerVNC can be installed with sudo apt install tigervnc-standalone-server and does not require an account. Configuration that is specific to RealVNC is outside the scope of this tutorial and should be handled according to its licensing and installation documentation. For most Ubuntu configurations, TigerVNC is the recommended option.

How Do I Connect Securely to a VNC Server on Ubuntu?

Run ssh -L 59000:localhost:5901 -C -N -f user@your_server_ip and configure the VNC viewer to connect to localhost:59000. SSH encrypts the tunneled traffic while TigerVNC remains bound to the loopback interface. SSH key-based authentication can also be used to secure access further.

How Do I Stop or Kill a VNC Server Session on Ubuntu?

Run vncserver -kill :1, replacing :1 with the display reported by vncserver -list. If systemd controls the VNC service, use sudo systemctl stop vncserver@1.service so that service management and logging remain consistent.

Which Desktop Environment Should I Use with VNC on Ubuntu Server?

XFCE is a practical default for headless server workloads because it keeps CPU, memory, and bandwidth requirements relatively low. GNOME is also suitable when its applications and desktop environment are required, but it needs additional system resources and should remain on Xorg for consistency with the TigerVNC configuration described here.

Conclusion

You installed TigerVNC on Ubuntu 22.04 or Ubuntu 24.04, configured xstartup for Xfce with GNOME as an optional alternative, checked the VNC listeners using vncserver -list and ss, and registered a systemd service so that the VNC server can return automatically after reboots. These steps provide the standard command-line workflow familiar from older TightVNC configurations while using packages that remain maintained in current Ubuntu repositories.

TigerVNC was kept on the loopback interface and connections were routed through SSH port forwarding. This provides a secure connection model without opening additional VNC ports in UFW or another firewall. When SSH key authentication is already configured, the SSH tunnel automatically uses the same authentication method without requiring additional VNC-specific configuration. Password-based SSH can be used in the same way.

Continue strengthening SSH with key-based authentication, explore additional SSH tunneling patterns when more advanced forwarding is required, and review the UFW firewall configuration whenever the network environment changes.

Source: digitalocean.com

Create a Free Account

Register now and get access to our Cloud Services.

Posts you might be interested in: