Install x11vnc Server on Ubuntu 20.04 for Remote Access

What is a X11VNC Server?

The Virtual Network Computing (VNC) allows to view and interact with devices remotely with any VNC viewer. When working with multiple RPIs, having VNC servers give us access all our RPIs from one device. There are many VNC servers and X11VNC is one of them. On another tutorial, we will install RealVNC, which is another vnc server, and I will go over the differences between X11VNC and RealVNC.

To learn more about X11VNC.

X11VNC is an alternative to Vino. If you’re happy with Vino, you don’t need to install x11vnc.

Let’s Install X11VNC Server on our Ubuntu

As a best practice, we shall update and upgrade our operating system.

sudo apt update && sudo apt upgrade -y

Now, we will need to change display manager to lightdm

sudo apt-get install lightdm

Let’s reboot the Raspberry Pi for these changes to take effect.

sudo reboot

The following command to install x11vnc server

sudo apt-get install x11vnc

Now, we will create our service configuration file.

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

Let’s copy and paste the following configuration into our newly create service file. These configurations will start the x11vnc server and make it run continuously. It will also force the server to restart automatically in case of any failure.

Note: yourPassword is the password.

[Unit]
Description=x11vnc service
After=display-manager.service network.target syslog.target

[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -forever -display :0 -auth guess -passwd yourPassword
ExecStop=/usr/bin/killall x11vnc
Restart=on-failure

[Install]
WantedBy=multi-user.target

The following commands to reload the systmd system and to enable and start the x11vnc service.

systemctl daemon-reload
systemctl enable x11vnc.service
systemctl start x11vnc.service
systemctl status x11vnc.service

We can check the status of our x11vnc server as shown.

x11vnc status

Finally, let’s reboot the RPI 4.

sudo reboot

Now, we are able to vnc into our RPI4 from any vnc viewer. We will need the Notice that x11vnc is warning us that we are running this server without a password. Well, let’s setup a password.

RPI

If you have not set your password in the previous step (yourPassword), you could use the following command to setup. You will be promoted to enter a password and to confirm it.

x11vnc -storepasswd 

Make sure you have received a similar success message,and that you’re password has been written, if not try it again.

password written to: /home/<your-login-name>/.vnc/passwd

Conclusion:

This concludes our x11vnc server installation on a Ubuntu 20.10 or 20.04 LTS installed on a RPI 4.