Prerequisites
Before using VNC Viewer to connect to an Ubuntu machine with TigerVNC, ensure the following setup is complete on the Ubuntu server:
sudo apt update && sudo apt install tigervnc-standalone-server tigervnc-common in the terminal to install the core components.vncpasswd and follow prompts to create a password (max 8 characters). This is required for client authentication.~/.vnc/xstartup file to define the desktop environment (e.g., GNOME/Xfce). For GNOME, use:#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
export XDG_SESSION_TYPE=x11
export GNOME_SHELL_SESSION_MODE=ubuntu
exec dbus-launch --exit-with-session gnome-session
Save the file, then run chmod +x ~/.vnc/xstartup to make it executable.vncserver :1 (replace :1 with your desired display number). This outputs the port number (e.g., 5901 for :1). Stop the server with vncserver -kill :1 if you need to modify xstartup.sudo ufw allow 5901/tcp (adjust port if using a different display number).Using VNC Viewer to Connect
VNC Viewer is available for Windows, macOS, and Linux. Below are steps for common platforms:
192.168.1.100:1 for :1). Click “Connect”.192.168.1.100:1). Press Enter.sudo apt install tigervnc-viewer for Ubuntu/Debian) to install TigerVNC Viewer.vncviewer from the terminal.192.168.1.100:1).Optional: Enhance Security with SSH Tunneling
To encrypt VNC traffic, set up an SSH tunnel between your local machine and the Ubuntu server. On your local machine, run:
ssh -L 5901:localhost:5901 your_username@your_server_ip
Replace your_username and your_server_ip with your actual credentials. Then, connect VNC Viewer to localhost:1 (or localhost:<display_number>). This routes traffic through SSH, securing the connection.
Troubleshooting Common Issues
~/.vnc/xstartup file is correctly configured (e.g., uses the right desktop environment) and has execute permissions. Restart the VNC server after making changes.vncserver -list), the firewall allows the port, and the IP address is correct.vncpasswd. Note that this only changes the VNC password, not your system login password.