1

OS: GNU/Linux Debian 9 with Cinnamon DE.

Since we managed to get VNC on Debian server running, thanks to GAD3R again, it's time to make VNC a regular service.

I want it to be running all the time, since boot, without having to SSH to server, while running:

x11vnc -rfbauth ~/.vnc/passwd

Also, I don't want to run a separate Cinnamon session, I want to see directly what's on the primary screen or whatever you call it, and manipulate with that session live.

4

Similar to Vlastimil's own solution, but with a few other details: (from VNC server for Cinnamon with systemd)

Create the file /etc/systemd/system/x11vnc.service :

[Unit]Description=VNC Server for X11
Requires=display-manager.service

[Service]
ExecStart=/usr/bin/x11vnc -display :0 -rfbauth /etc/x11vnc.pwd -shared -forever -o /var/log/x11vnc.log
ExecStop=/usr/bin/x11vnc -R stop
Restart=on-failure
RestartSec=2

[Install]
WantedBy=multi-user.target

Set the VNC password (replace MY_PASSWORD)

x11vnc -storepasswd MY_PASSWORD /etc/x11vnc.pwd

Finally:

systemctl daemon-reload
systemctl enable x11vnc
systemctl start x11vnc
2

First, it might be a good idea to copy the password file under /etc/, something like:

sudo cp ~/.vnc/passwd /etc/vnc.passwd

This also ensures the ownership to root and his rw access, as confirmed by:

$ ll /etc/vnc.passwd

-rw------- 1 root root 8 Nov  3 04:00 /etc/vnc.passwd

Second, we have to create the service file ourselves:

sudo nano /lib/systemd/system/vnc.service

while the simplest solution I came up with is for it to contain:

[Unit]
Description=Start x11vnc at startup.
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /etc/vnc.passwd -rfbport 5900 -shared

[Install]
WantedBy=multi-user.target

Note, while it is by far the simplest service file, it can't even have support for stop or restart, I myself need to figure this out yet.

Disclaimer: The man page is quite lengthy, and maybe I've made some serious, e.g. security mistake here. Use on your own risk.

sudo systemctl enable vnc.service
sudo systemctl daemon-reload

and you may simply reboot the machine.


As a side-note, on the client-side, you may want to copy the password file from the server for you not to enter a password each time, you connect, and define some alias similar to:

alias vnc-server='(vncviewer 192.168.0.xxx:5900 -passwd /home/UserName/.vnc/server.passwd > /dev/null 2>&1 &)'

so that it won't flood your terminal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.