Step 1 – we want the VNC server to have a password, just in case – the VNC port shouldn’t really be exposed to the outside world – it’s easy to wrap it in an SSH connection to encrypt everything for you (see here for a good explanation of how to set that up).
sudo x11vnc -storepasswd /etc/x11vnc.pass
This will prompt you for a password to (lightly) secure your VNC server.
Step 2a (for LightDM – XUbuntu, and all Ubuntu variants 12.04 onwards) – create the upstart job. Put this in /etc/init/x11vnc.conf :
start on login-session-start
/usr/bin/x11vnc -xkb -auth /var/run/lightdm/root/:0-noxrecord -noxfixes -noxdamage -rfbauth /etc/x11vnc.pass-forever -bg -rfbport 5900-o /var/log/x11vnc.log