Install VNC Server on Linux Mar 4th 2021 Words: 163

Guide

Install the executable with package manager

sudo pacman -S x11vnc

Create a password for incomming connections

sudo x11vnc -storepasswd /etc/x11vnc.passwd

Use systemd to daemonize the service

1
2
3
4
5
6
7
8
9
10
11
[Unit]
Description=VNC Server
After=multi-user.target network.target

[Service]
Restart=no
# Set password by running `sudo x11vnc -storepasswd /etc/x11vnc.passwd`
ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc.passwd -rfbport 5900 -shared

[Install]
WantedBy=graphical.target

The systemd part is rather tricky, -auth guess does not work well, you have to find the right file for the DM using ps wwwaux | grep auth.

Sometimes the command works fine in bash, but have trouble run with systemd, try wrap the command like below:

ExecStart=/bin/bash -c "/usr/bin/x11vnc -display :0 -auth $(find /var/run/sddm/ -type f) -forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc.passwd -rfbport 5900 -shared"

Reference

ArchWiki - x11vnc