Install and Configure TightVNC on Ubuntu

After connecting to your server with SSH, update your list of packages:

sudo apt update

Now install Xfce along with the xfce4-goodies package, which contains a few enhancements for the desktop environment:

sudo apt install xfce4 xfce4-goodies

install the TightVNC server:

sudo apt install tightvncserver

Next, run the vncserver command to set a VNC access password, create the initial configuration files, and start a VNC server instance:

vncserver

Note that if you ever want to change your password you can do so with the vncpasswd command:

vncpasswd

Configuring the VNC Server

Because you are going to be changing how the VNC server is configured, first stop the VNC server instance that is running on port 5901 with the following command:

vncserver -kill :1

Before you modify the xstartup file, move it to a back up file:

mv ~/.vnc/xstartup ~/.vnc/xstartup.bak

Now create a new xstartup file and open it in a text editor, such as nano:

nano ~/.vnc/xstartup

Then add the following lines to the file:

#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &

Save and close the file after adding these lines. If you used nano, do so by pressing CTRL + X, Y, then ENTER.

To ensure that the VNC server will be able to use this new startup file properly, you’ll need to make it executable:

chmod +x ~/.vnc/xstartup

Then restart the VNC server:

vncserver

How to Install and Configure VNC on Ubuntu 22.04 | DigitalOcean