sudo apt update && sudo apt install -y x11vnc
x11vnc -storepasswd
Saves the password in ~/.vnc/passwd.
If you just want remote control after logging in:
x11vnc -auth guess -display :0 -usepw -forever
sudo nano /etc/systemd/system/x11vnc.service
Paste:
[Unit]
Description=Start x11vnc at login screen
After=display-manager.service
Wants=display-manager.service
[Service]
ExecStart=/usr/bin/x11vnc -auth /var/lib/lightdm/.Xauthority -display :0 \
-usepw -forever -loop -noxdamage \
-rfbauth /home/your_user/.vnc/passwd -rfbport 5900 -shared
Restart=always
User=root
[Install]
WantedBy=multi-user.target
!! Replace
your_userwith your actual username.
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/24with your actual ip range.
sudo systemctl daemon-reload
sudo systemctl enable x11vnc
sudo systemctl start x11vnc
Check status:
sudo systemctl status x11vnc
x11vnc -usepw -display :0
Install TigerVNC Viewer : https://tigervnc.org/
Open the viewer, enter your Debian IP with port 5900:
192.168.150.10:5900
Enter the password you set with x11vnc -storepasswd
Done (you should see the same screen, including login screen)
If connecting over the internet:
Open PuTTY on Windows.
Go to Connection : SSH : Tunnels
5900localhost:5900Connect to your Debian SSH server.
In TigerVNC Viewer, connect to:
localhost:5900
Stop and disable service:
sudo systemctl stop x11vnc
sudo systemctl disable x11vnc
sudo systemctl status x11vnc
Remove service file:
sudo rm /etc/systemd/system/x11vnc.service
sudo systemctl daemon-reload
sudo systemctl reset-failed
Remove package + cleanup:
sudo apt remove --purge -y x11vnc
sudo apt autoremove -y
Delete password + config:
rm -rf /home/your_user/.vnc/passwd
rmdir /home/your_user/.vnc
Summary
x11vnc shares the physical desktop (not a virtual session).