Installed VNC using rasp-config
=> Interface options => VNC
Wanted to avoid having port 5900 listening on the local subnet (0.0.0.0:5900) but only available if I SSH to the box and connect via SSH tunnel
1 2 3 | # create /etc/vnc/config.d/vncserver-x11 # contents localhost=1 |
After the above setting and restart the Local Address changes from (0.0.0.0:5900 to 127.0.0.1:5900)
1 2 3 4 | sudo netstat -apn | grep 5900 # output tcp 0 0 127.0.0.1:5900 0.0.0.0:* LISTEN 812 /vncserver-x11-c tcp6 0 0 ::1:5900 :::* LISTEN 812 /vncserver-x11-c |
Overriding a SystemD unit file
The problem with copilot
it was telling me to edit the unit file and add `-listen 127.0.0.1` and all sorts of other solutions but none seemed to work for me.
But in trying the solutions it offered I found out how to edit and override a systemd unit file as follows
1 | sudo systemctl edit vncserver-x11-serviced.service |
Next was to edit to taste but make sure you clear ExecStart with ExecStart=

After editing the unit file you need to make sure systemd knows it has changed
1 2 3 | sudo systemctl daemon-reexec # restarts systemd process more extreme sudo systemctl daemon-reload # this is usually all that is needed as it will re-read the changed unit files sudo systemctl restart vncserver-x11-serviced.service # then restart the changed process |
0 Comments