First install the x11vnc
sudo apt-get install x11vnc
Then, Set the vnc password
sudo x11vnc -storepasswd /etc/x11vnc.pass
Then open the service file
sudo nano /lib/systemd/system/x11vnc.service
And, Insert the following text
[Unit] Description="x11vnc"
Requires=display-manager.service
After=display-manager.service
[Service]
ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /etc/x11vnc.pass
ExecStop=/usr/bin/killall x11vnc
Restart=on-failure
Restart-sec=2
[Install] WantedBy=multi-user.target
Then starts with
sudo systemctl daemon-reload
sudo systemctl start x11vnc
And make sure the service starts on boot:
sudo systemctl enable x11vnc
Now x11vnc will start before even you logged in once machine starts