$ sudo apt install tightvncserver
$ sudo ufw allow VNC $ sudo ufw allow 5902/tcp
$ sudo vim /etc/systemd/system/vncserver@.service
[Unit] Description=Start TightVNC server at startup After=syslog.target network.target [Service] Type=forking User=<user> Group=<user> WorkingDirectory=/home/<user> PIDFile=/home/<user>/.vnc/%H:%i.pid ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1 ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 -dpi 96 :%i ExecStop=/usr/bin/vncserver -kill :%i [Install] WantedBy=multi-user.target
The ExecStartPre command stops VNC if it’s already running, make sure the command is preceded by a “-”. The ExecStart command starts VNC and sets the color depth to 24-bit color with a resolution of 1920×1080 and dpi to 96 which ensures the fonts are large enough.
$ sudo systemctl daemon-reload
$ sudo systemctl enable vncserver@1.service
The 2 following the @ sign signifies which display number the service should appear over, in this case the default :1.
vncserver -kill :1
/tmp/.X2-lock /tmp/.X11-unix/X2
$ sudo systemctl start vncserver@1
$ sudo systemctl is-active vncserver@1 $ sudo systemctl status vncserver@1
In my setup I attach the hard disks only after the encryption has been confirmed by password. This makes running the service at boot time not possible. In this case, you need to start the vncserver after the hard disk has been attached and the user folders are available.
$ sudo systemctl disable vncserver@1.service
$ sudo systemctl start vncserver@1.service
snapd
through your VNC connection you need to tweak the permissions to access the X server.$ xhost +
/etc/Xn.hosts
, where n
is the display number of the server. If this file exists and contains the following line running xhost
is not required.local: