This episode builds VNC's first line of defense: understanding vncpasswd and the 8-character password limitation, view-only passwords, access restrictions with -localhost and binding to specific interfaces, and firewall rules that only allow specific client IPs.

So far you've focused on making VNC work. Starting with episode 12, we turn around: how to make VNC hard to compromise. Let's be honest — VNC's built-in authentication is weak. The password is short, the screen transfer isn't encrypted, and many implementations open themselves to the entire network by default.
This episode builds the first layer of defense: understanding the vncpasswd limitations, using view-only passwords, restricting access with -localhost and binding to specific interfaces, and configuring the firewall so only allowed client IPs can get in. Full encryption follows in episodes 13 and 14.
The main tool for VNC authentication is vncpasswd. It creates the password file the server reads to validate clients:
vncpasswd
vncpasswd -f > ~/.vnc/passwdThe vncpasswd command runs interactively and writes to ~/.vnc/passwd. The -f option allows the password to be read from a separate input — useful when creating passwords for several users in a script.
This is a fundamental weakness you must understand: classic VNC authentication only uses the first 8 characters of the password. The remaining characters are ignored, and verification uses DES with a derivation key that's already publicly known. The consequences:
x11vnc -storepasswdBecause of this limitation, never rely on a VNC password alone. The password is only the first layer; transport encryption (TLS/SSH) is the layer that closes the real gap, and it will be covered in episodes 13-14.
Warning
Never use guessable words or dates as your VNC password. With the 8-character limit, every memorability shortcut is a weakness that can be exploited faster.
Some VNC implementations allow two classes of passwords: one for full control, another that can only view the screen. In x11vnc, use -viewpasswd:
x11vnc -display :0 -rfbauth /etc/x11vnc.pass -viewpasswd /etc/x11vnc-view.passThe x11vnc -display :0 -rfbauth /etc/x11vnc.pass -viewpasswd /etc/x11vnc-view.pass command makes connections with the main password able to control the screen, while connections with the second password can only view — no typing or mouse movement.
This feature is ideal for presentation scenarios: participants can follow the screen, only one presenter controls it. Combine it with the clipboard restrictions discussed in episode 11 for a truly locked-down session.
The strictest way to restrict access is -localhost, which makes the server listen only on 127.0.0.1. No other machine on the network can connect directly:
x11vnc -display :0 -rfbauth /etc/x11vnc.pass -localhost
vncserver :1 -localhost -geometry 1920x1080The vncserver :1 -localhost -geometry 1920x1080 command starts a virtual display that can only be accessed from the machine itself. This is the safest pattern: VNC stays dead to the network, and access is opened only through an SSH tunnel (episode 14).
If the server has several network interfaces, you can bind VNC to only one internal interface with the -listen option in x11vnc:
x11vnc -display :0 -rfbauth /etc/x11vnc.pass -listen 192.168.1.20x11vnc -listen 192.168.1.20 makes the server listen only on the internal address, so VNC isn't visible from the public interface. Verify with ss:
ss -tulpn | grep 5900The firewall is the defense layer that governs who can reach the port. On Debian/Ubuntu with ufw, allow only one client IP to the VNC port:
sudo ufw allow from 192.168.1.100 to any port 5900 proto tcp
sudo ufw status verboseThe sudo ufw allow from 192.168.1.100 to any port 5900 proto tcp command creates a rule that opens port 5900 only for that IP — all other IPs are denied.
On the RHEL family, the same rule is written as a rich rule:
sudo firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=192.168.1.100 port port=5900 protocol=tcp accept'
sudo firewall-cmd --reloadfirewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=192.168.1.100 port port=5900 protocol=tcp accept' stores a permanent rule that only accepts connections from 192.168.1.100. Change the address to match your client IP — don't spread access across the whole subnet.
Overall, basic VNC defense should ideally be layered:
-localhost.password + view-only + bind/interface + firewall -> secure VNC serverEpisode 12 built the first line of defense: understanding the weak 8-character VNC password, separating control rights with view-only passwords, restricting access via -localhost and interface binding, and closing the port with a firewall that only allows client IPs.
Key takeaways:
-viewpasswd creates connections that can only view the screen.-localhost and -listen restrict access on the server side.In the next episode, episode 13, we close VNC's biggest weakness: encryption — the plaintext VNC problem that can be sniffed, activating TLS/SSL in x11vnc and TigerVNC, and why an SSH tunnel is a mandatory encryption layer. See you there!