sudo apt install tigervnc-standalone-server
vncserver
Enter n
for view only mode
vncpasswd
Kill active instance vncserver -kill :1
Create new file if not present nano ~/.vnc/xstartup
#!/bin/sh
# Start Gnome 3 Desktop
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
vncconfig -iconic &
dbus-launch --exit-with-session gnome-session &
Set as executable chmod +x ~/.vnc/xstartup
Restart server as insecure vncserver -localhost no :1
Connect with any VNC client hostname|ipaddress:5901
Once verified kill insecure session vncserver -kill :1
On the guest machine you need ssh setup and installed.
Create a ssh tunnel ssh -L 59000:localhost:5901 -C -N -l server_user_name server_ip_address
add -f
flag to run in the background
Connect with any VNC client to tunneled local port localhost:59000
This might give warning as insecure, ignore it as the local port is tunneled via ssh.
Create unit file in the host system sudo nano /etc/systemd/system/[email protected]
[Unit]
Description=Start TigerVNC server at startup
After=syslog.target network.target
[Service]
Type=forking
User=YOUR_USERNAME # change as needed
Group=YOUR_USERNAME # change as needed
WorkingDirectory=/home/YOUR_USERNAME # change here
PIDFile=/home/YOUR_USERNAME/.vnc/%H:%i.pid # change here
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 -localhost :%i # set resolution if needed
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
Kill any exisiting vnc sessions vncserver -kill :1
Enable and restrart the systemd
sudo systemctl enable [email protected]
sudo systemctl daemon-reload
Start the vncserver with systemd sudo systemctl start vncserver@1
Check status with sudo systemctl status vncserver@1
Might show blank screen for some, check configuration for xstartup and make changes there