Successfully running x11vnc as a Systemd Service in Xubuntu 16.04 (Xenial Xerus)

I found many posts about running x11vnc at boot up on various flavors of Ubuntu 16.04 (Xenial Xerus). None of the posted suggestions would work for me as-is. I ended up finding a solution that works on Xubuntu 16.04 (Xenial Xerus), so am posting just the Systemd service file here as a suggestion of what works for me:

Description=x11vnc VNC Server for X11

ExecStart=/usr/bin/x11vnc -auth /var/run/lightdm/root/:0 -display WAIT:0 -ncache 10 -forever -nevershared -bg -o /var/log/x11vnc.log -rfbauth /etc/x11vnc.pass -rfbport 5900 -xkb -norc -noxrecord -noxdamage -nomodtweak
ExecStop=/usr/bin/killall x11vnc


This solution successfully runs x11vnc at the Xubuntu login screen. Such a bonus!

Type=forking was imperative from what I can see as x11vnc appears to fork once a connection successfully authenticates. Without the service defined as that, the connection drops once authentication is successful... NOT at all helpful!

I needed to add the WAIT to the :0 arg. And -nofixes needed to be skipped else mouse pointers did not come across to the remote control side correctly. The -ncache 10 was suggested by the program in its log file, so I decided to give it a try.


systemd is a p* in the a*

Had to deal with this a year ago - after I found out you cannot start x11vnc traditionally and simple with your displaymanager anymore in a systemd system.

Small note:
Of course you had to use type=forking because you tell it to fork by using "-bg".

On Debian (with lightdm) I run it like this

Description=VNC Server for X11

ExecStart=/usr/bin/x11vnc -xkb -repeat -allow -display :0 -auth guess -rfbauth /etc/X11/x11vnc.passwd -rfbport 5900 -forever -loop -o /var/log/x11vnc.log

"-repeat" can be a little problematic sometimes and you want to probably leave that out
"-allow" of course only binds it to localhost interface so you can only reach it from outside through a suitable (vpn-) tunnel, you probably want to list your localnet there, too.
Like e.g. "-allow,192.168.1."
Other switches like "-noxdamage" and similar probably depend on what displaymanager or windowmanager you are running. Above works just fine with lightdm and xfce.
Hope this helps.



I too found all the other found solutions lacking, especially ones tied to Upstart, which is tied to the userspace on newer versions of Ubuntu.

This is where the file goes:

To update the config without reloading:
systemctl daemon-reload

Restart the service to test:
systemctl restart x11vnc.service

I had to remove "-ncache 10", the VNC on the client side looked all messed up, but I kept the rest of the arguments.

This is on Ubuntu 16.04 LTS. The client used is a Windows 7 Professional x64 machine.