sudo apt update && sudo apt install -y x11vnc
x11vnc -storepasswd
This saves the password file at ~/.vnc/passwd
initially.
If remote control is only needed after user login:
x11vnc -auth guess -display :0 -usepw -forever
Since systemd service runs as root:
sudo mkdir -p /etc/x11vnc
sudo mv /home/your_user/.vnc/passwd /etc/x11vnc/passwd
sudo chown root:root /etc/x11vnc/passwd
sudo chmod 600 /etc/x11vnc/passwd
Replace
your_user
with your actual username.
sudo nano /etc/systemd/system/x11vnc.service
Paste this content:
[Unit]
Description=Start x11vnc at login screen
After=display-manager.service
Wants=display-manager.service
[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -auth guess -display :0 \
-forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc/passwd \
-rfbport 5900 -shared
Restart=on-failure
RestartSec=5
User=root
[Install]
WantedBy=multi-user.target
The key option here is -auth guess
which dynamically finds the correct X authority file to avoid black screens after locking.
sudo systemctl daemon-reload
sudo systemctl enable x11vnc
sudo systemctl start x11vnc
sudo systemctl status x11vnc
To fix the black screen in VNC after locking:
sudo apt remove -y light-locker
sudo apt install -y xscreensaver xscreensaver-data
Enable xscreensaver autostart:
xscreensaver -nosplash
Or ensure the "Screen Saver" entry exists and is enabled.
Reboot:
sudo reboot
sudo apt install -y ufw gufw
sudo ufw allow from 192.168.150.0/24 to any app VNC
sudo ufw enable
sudo ufw reload
sudo ufw status verbose
Replace
192.168.150.0/24
with your actual IP subnet.
Install TigerVNC Viewer: https://tigervnc.org/
Connect to:
192.168.150.10:5900
Enter VNC password set earlier.
View and control your Debian desktop, including login and locked screens.
Use SSH tunneling for encryption:
5900
to localhost:5900
.localhost:5900
.sudo systemctl stop x11vnc
sudo systemctl disable x11vnc
sudo rm /etc/systemd/system/x11vnc.service
sudo systemctl daemon-reload
sudo systemctl reset-failed
sudo apt remove --purge -y x11vnc
sudo apt autoremove -y
sudo rm -f /etc/x11vnc/passwd
rm -rf /home/your_user/.vnc/passwd
rmdir /home/your_user/.vnc
x11vnc
shares your real desktop (:0
), not a virtual session.-auth guess
in systemd to avoid black screen after lock./etc/x11vnc/passwd
for root access by systemd.light-locker
with xscreensaver
on Debian XFCE for VNC lock screen compatibility.This setup ensures a reliable, continuous remote desktop experience on Debian XFCE via x11vnc.