First, update your package lists:
sudo apt update
Install Xfce
sudo apt install xfce4 xfce4-goodies
Install TightVNC
sudo apt install tightvncserver
run the vncserver
Create a VNC password to access the remote desktop, create initial configuration files and initialize a VNC server instance.
vncserver
# When it asked you about viw-only password: no --> this
# will allow you to control the machine not just view it.
An instance of the VNC Server will be created on the display port which is port 5901, and referenced by :1 notation. In addition, all the necessary VNC Server configuration files will be created and placed in your home directory in the ~/home/user/.vnc path.
Configuring the ThghtVNC server
- Kill the current VNC server instance by :
- Edit the xstartup file. Make sure to make a backup first.
- Change this file [nano ~/.vnc/xstartup] to be like this
- Save that file and make it executable.
- Restart the VNC Server
- Establish an SSH tunnel from a local machine to the server
# :1 reflects the number of the instance currently runing
vncserver -kill :1
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
nano ~/.vnc/xstartup
#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &
chmod +x ~/.vnc/xstartup
# this will run VNC server on the loop back (127.0.0.1)
# But that is fine because later I will connect to it using
# ssh tunneling.
vncserver -localhost
# To start the VNC server in the same resolution your monitor do this
vncserver -localhost -geometry 1920x1200
# 59000 is the local machine port
# the 5901 is the VNC server port
# saleh is the user at the VNC server
# the vnc_server_ip is the ip for the server
# -C: Ths flag enables compression which helps in the optimization of resource usage.
# -N: Instructs SSH that you don’t intend to execute any remote commands.
# -l: Specifies the login user and the VNC server IP address
ssh -L 59000:localhost:5901 -C -N -l saleh vnc_server_ip
On the popup dialogue, enter the address shown. Then click ‘connect’
Provide the remote user’s password and click ‘OK’