Categories
ubuntu

x11vnc Server on Ubuntu 20.04

I desired a fast VNC solution for use within my local network for a couple machines. One, a desktop running Ubuntu 20.04 with Gnome and another a Raspberry Pi 4B+ (4G). After some research I decided on x11vnc as the VNC server running as a systemd service. After a straightforward installation all that was needed was a little configuration and the addition of a service file.

Installation

$ sudo apt-get install x11vnc -y

Create a Password File

$ sudo x11vnc -storepasswd <filename>
x11vnc password entry on ubuntu 20.04.
Command line entry of x11vnc server password.

Configure Service & Start Up

Since the installation does not come with a service ready if one wishes to have their VNC server as a service (recommended) then there are a few simple steps to allow x11vnc to be managed by systemd.

First we create the systemd.service file named x1vnc.service, or whatever you like. Place this file in the folder /lib/systemd/system. After the file is created systemctl will be able to control the service from then on. This means enabling/disabling, starting/stopping, and restarting with systemctl.

On to the code:

$ sudo nano /lib/systemd/system/x11vnc.desktop

Now with the file open enter the necessary entries for your use. You will find in the man pages there are lots of options. I am providing basic ones here and it will work but again, I’m only using this for a connection locally on my internal network. If you plan on using this from outside your local network, like connecting to a home machine from your favorite cafe, do be meticulous about security.

[Unit]
Description=Start x11vnc at startup.
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -display :0 -auth /run/user/1000/gdm/Xauthority -rfbauth /etc/x11vnc.pass -noipv6 -allow 192.168.10.12 -forever -loop -noxdamage -repeat -rfbport 5900
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

Now that the file is complete let’s try to start it. Open another terminal to view the syslog/journal so you are aware of any errors, etc.

$ journalctl -xeafm

With the journal being tailed any output upon restart of the service should immediately be shown. Hopefully all is well and nothing needs tweaking but …

$ sudo systemctl enable x11vnc.service
$ sudo systemctl start x11vnc.service

Connect From Another Machine

Instead of going outside Gnome defaults of sorts I chose Remmina as the client application to connect to the newly running VNC server. On the client machine, open up Remmina. If you haven’t yet got it installed, install it:

$ sudo apt-get install remmina -y

The GUI for Remmina is below. The drop-down allows for several protocols (RDP, VNC, SSH) and VNC is chosen as shown below. Enter the IP address or hostname of the machine you are connecting to (if your machine knows the hostname’s IP to resolve) and hit the [Enter] key.

Leave a Reply