Install VNC server x11vnc on Ubuntu 18.04 and add to startup

This series of articles on installing a VNC server for remote desktop connection

  • Installing VNC Server x11vnc on Ubuntu 16.04 and adding to startup
  • Install VNC server x11vnc on Ubuntu 18.04 and add to startup

Install x11vnc

[email protected]:~$ sudo apt-get install x11vnc

Create a connection password

[email protected]:~$ mkdir /home/user/.vnc/
[email protected]:~$ sudo x11vnc -storepasswd /home/user/.vnc/passwd
Enter VNC password: 
Verify password:    
Write password to /home/user/.vnc/passwd?  [y]/n 
Password written to: /home/user/.vnc/passwd

To create a service and add it to startup, create a file

[email protected]:~$ sudo nano /lib/systemd/system/x11vnc.service

[Unit]
Description=Start x11vnc at startup.
After=multi-user.target
[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -auth /home/user/.Xauthority -forever -loop -noxdamage -repeat -rfbauth /home/user/.vnc/passwd -rfbport 5900 -shared -display :1 -ncache 10 -bg -o /var/log/x11vnc.log
[Install]
WantedBy=multi-user.target

We reboot systemctl, add the created file to autoload and start

[email protected]:~$ sudo systemctl daemon-reload
[email protected]:~$ sudo systemctl enable x11vnc.service
[email protected]:~$ sudo systemctl start x11vnc.service
Sidebar