Virtual Network Computing (VNC) is a graphical desktop system that allows remote control of another computer.
This guide is prepared for the Ubuntu 24.04 OS.
Starting from our system updates
To do so, use:
sudo apt update
sudo apt upgrade
Install a Desktop Environment
Ubuntu 24.04 comes with GNOME by default, but you can also install other desktop environments, such as XFCE. To install XFCE, use:
sudo apt install xfce4 xfce4-goodies
Installing the TigerVNC service
To install the TigerVNC server, use:
sudo apt install tigervnc-standalone-server tigervnc-common
Now, we need to set a password for our VNC service:
vncpasswd
Output example:
You will be asked to enter and verify a password.
You can set a view-only password, but this is optional.
Configure VNC Server
We need to create a configuration file.
First, we start the VNC service:
vncserver
It will create a default configuration directory and show your port and DisplayPort:
We can stop the VNC service for now:
vncserver -kill :1
The second step is editing xstartup configuration file:
nano ~/.vnc/xstartup
Add the following to the file configuration:
#!/bin/sh
xrdb
$HOME/.Xresources
startxfce4 &
Example of the file:
Make it executable:
chmod +x ~/.vnc/xstartup
Start the VNC server:
vncserver
Pay your attention to the DisplayPort (e.g., :1), as you will need to use this when connecting. Output example:
Connect to the VNC Server
You can use any VNC client (TigerVNC or TightVNC) on your local machine. Open your VNC client and enter your server’s IP address, followed by the DisplayPort:
your_server_ip:1
Enter the VNC password to gain access to your remote desktop.
Firewall
If your server has a firewall enabled, please open the appropriate ports. VNC typically runs on port 5900. For example, if your DisplayPort is :1, you will need to open the port 5901.
Run the commands to allow the port 5901:
sudo ufw allow 5901/tcp
To check if the firewall is enabled, use:
sudo ufw status
You have successfully set up the firewall and the VNC server.



