How to Install and Configure VNC on Ubuntu 24.04
Learn how to install and configure VNC on Ubuntu 24.04 LTS using TigerVNC and XFCE. Secure your VNC desktop with systemd service and SSH tunneling.

6 min read
Learn how to install and configure VNC on Ubuntu 24.04 LTS using TigerVNC and XFCE. Secure your VNC desktop with systemd service and SSH tunneling.
- Prerequisites and Supported Releases
- Step 1: Updating System and Installing Desktop Environment (XFCE)
- Step 2: Installing TigerVNC Server
Virtual Network Computing (VNC) is a graphical desktop-sharing system that uses the Remote Frame Buffer (RFB) protocol to remotely control another computer across a network. It transmits keyboard and mouse events from the client to the server while streaming graphical display updates back to the client. For system administrators, developers, and educators managing headless cloud instances or remote workstations, VNC provides a flexible way to interact with graphical tools without sitting directly in front of the physical machine.
While traditional RDP servers like Xrdp integrate well with Windows, VNC remains the universal cross-platform standard for Linux desktop sharing, supporting lightweight window managers, custom display geometries, and multi-user concurrent sessions. Learning how to install and configure vnc on ubuntu 24.04 allows you to construct a fast, customizable remote workstation on any Ubuntu server.
In this step-by-step tutorial, we demonstrate how to set up TigerVNC (the modern, high-performance VNC server standard) on Ubuntu 24.04 LTS (Noble Numbat). We guide you through installing the responsive XFCE desktop environment, creating desktop startup scripts, running VNC as a managed systemd background service, and tunneling VNC traffic through an encrypted SSH tunnel to eliminate security vulnerabilities.
Install and configure a secure TigerVNC server on Ubuntu 24.04 LTS with the lightweight XFCE desktop environment, managed systemd background service, and encrypted SSH tunnels.
Prerequisites and Supported Releases
This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat). The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.
Before proceeding, ensure you have the following requirements satisfied:
- A server or virtual machine running
Ubuntu 24.04 LTS. - A non-root user account configured with
sudoadministrative privileges. - At least
2 GB of RAM(4 GB recommended for responsive graphical applications). - A VNC client (such as TigerVNC Viewer, RealVNC, TightVNC, or Remmina) installed on your local computer.
Step 1: Updating System and Installing Desktop Environment (XFCE)
Standard Ubuntu Server installations do not include a graphical desktop environment. Before a VNC server can broadcast a graphical session, a window manager and desktop shell must be present on the host.
While you can install the default GNOME desktop (ubuntu-desktop), GNOME consumes significant RAM and 3D acceleration resources, often resulting in sluggish remote performance over network connections. XFCE is lightweight, remarkably fast, and provides optimal responsiveness for remote desktop protocols.
Update your package repositories and install XFCE and its supporting desktop utilities using APT.
# Update repository indices
sudo apt update && sudo apt upgrade -y
# Install lightweight XFCE4 desktop environment
sudo apt install -y xfce4 xfce4-goodies
Step 2: Installing TigerVNC Server
Ubuntu 24.04 includes several VNC implementations, including TightVNC, x11vnc, and TigerVNC. TigerVNC is actively maintained, supports modern TLS encryption extensions, and delivers significantly faster frame rendering than legacy VNC implementations.
Install the TigerVNC standalone server and common utilities from the official Ubuntu repositories.
Verify that the vncserver executable is installed and available in your system path.
# Install TigerVNC standalone server
sudo apt install -y tigervnc-standalone-server tigervnc-common
# Verify installation
vncserver -version
Step 3: Initializing VNC Password and Initial Files
Each user running a VNC server must configure an access password. The password is encrypted and stored in the user's home directory at ~/.vnc/passwd.
Execute the vncpasswd command as your standard unprivileged user. When prompted, enter a password between 6 and 8 characters.
When asked whether you would like to enter a view-only password, enter n unless you specifically need to share a read-only presentation screen.
# Set the VNC access password
vncpasswd
# Ensure secure permissions on the .vnc directory
chmod 700 ~/.vnc
Step 4: Configuring the Desktop Startup Script (xstartup)
When TigerVNC starts a virtual display, it executes a shell script located at ~/.vnc/xstartup to launch the graphical environment. If this script is missing or lacks executable permissions, VNC will display a blank gray screen with a crosshair cursor.
Create a new configuration script at ~/.vnc/xstartup.
Instruct the script to unset window manager session variables, start the D-Bus message daemon, and launch the XFCE desktop session (startxfce4).
Grant executable permissions to the script using chmod +x.
# Create the custom xstartup configuration script
cat <<'EOF' > ~/.vnc/xstartup
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
exec dbus-launch --exit-with-session startxfce4
EOF
# Make xstartup executable
chmod +x ~/.vnc/xstartup
Step 5: Creating a Managed Systemd Service for VNC
To manage your VNC server like any standard Ubuntu service (with automatic startup on boot and graceful restarts), create a template systemd unit file.
Create a unit file named /etc/systemd/system/[email protected] using administrative privileges.
This parameterized unit allows multiple users to run independent VNC displays (such as :1, :2) simply by specifying the display number in the service name.
Replace your_username with your actual Ubuntu username in the configuration.
# Create systemd service template
sudo bash -c 'cat <<EOF > /etc/systemd/system/[email protected]
[Unit]
Description=TigerVNC Server for display :%i
After=syslog.target network.target
[Service]
Type=forking
User=ubuntu
Group=ubuntu
WorkingDirectory=/home/ubuntu
PIDFile=/home/ubuntu/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver :%i -depth 24 -geometry 1920x1080 -localhost no
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
EOF'
# Note: Replace User=ubuntu, Group=ubuntu, and home paths with your active username
Step 6: Enabling and Starting the VNC Service
Reload the systemd manager configuration to register the newly created service template.
Enable and start the service for display :1. VNC display :1 corresponds to TCP port 5901 (display :2 maps to 5902, and so on).
Check the service status to verify that the daemon is active and listening.
# Reload systemd daemon
sudo systemctl daemon-reload
# Enable and start VNC server on display :1
sudo systemctl enable --now [email protected]
# Check service status
sudo systemctl status [email protected] --no-pager
Step 7: Securing VNC via an Encrypted SSH Tunnel
VNC is an inherently unencrypted protocol. Standard VNC passwords and desktop screen buffers are transmitted across the wire in plaintext, making them vulnerable to network packet sniffing on public networks.
Rather than opening port 5901 in your UFW firewall, keep port 5901 closed and connect exclusively through an SSH Tunnel.
Execute the following SSH port-forwarding command from your local computer's terminal. This tunnels traffic from local port 5901 securely to remote port 5901 on your Ubuntu server.
# Run from your LOCAL computer terminal to establish encrypted tunnel:
ssh -L 5901:127.0.0.1:5901 -N -f -l ubuntu your_server_ip
# The tunnel will forward localhost:5901 to the remote server over SSH
Step 8: Connecting from Your VNC Client
With your SSH tunnel established, open your favorite VNC viewer application (such as TigerVNC Viewer, RealVNC Viewer, or Remmina) on your local computer.
In the connection field, enter the local loopback address: localhost:5901 (or 127.0.0.1:5901) and click Connect.
When prompted, enter the VNC password you created in Step 3.
Within moments, your remote XFCE desktop session will appear in a responsive window, allowing complete graphical management over your Ubuntu 24.04 instance.
# Check active listening ports on the server
sudo ss -tulpn | grep 5901
Troubleshooting and Common Errors
When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:
Gray screen with black 'X' cursor after connecting
Resolution: This indicates that the desktop environment failed to launch. Verify that ~/.vnc/xstartup has executable permissions (chmod +x ~/.vnc/xstartup), ensure xfce4 is installed, and confirm dbus-x11 is present by running sudo apt install -y dbus-x11.
VNC connection refused on port 5901
Resolution: Check whether the VNC service is running with sudo systemctl status [email protected]. Inspect the server log file at ~/.vnc/:1.log for error traces.
A VNC server is already running as :1
Resolution: If a stale lockfile prevents startup, stop the service and remove the leftover lock and socket files: vncserver -kill :1 and rm -rf /tmp/.X1-lock /tmp/.X11-unix/X1.
Security Best Practices and Hardening
Never expose port 5901 directly to the public internet without an SSH tunnel or VPN. Raw VNC traffic is unencrypted and easily intercepted.
Always configure vncserver to bind to localhost only by passing the -localhost yes flag in /etc/systemd/system/[email protected].
Use strong VNC passwords and restrict SSH access to public-key authentication only.
Regularly audit active VNC sessions on your server by inspecting ~/.vnc/*.log and running vncserver -list.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
-geometry 1920x1080 flag in your service file.sudo systemctl stop [email protected], or kill the display manually by executing vncserver -kill :1.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
Rajesh Ray
I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides


Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!