一、安装X11VNC服务
sudo apt-get install x11vnc
二、配置连接VNC的密码
sudo x11vnc -storepasswd <password> /etc/x11vnc.pass
sudo chmod +r /etc/x11vnc.pass
mkdir /home/uos/.vnc
cp /etc/x11vnc.passwd /home/<user>/.vnc/passwd
三、配置systemd服务并启用开机自启动
sudo vim /lib/systemd/system/x11vnc.service
[Unit]
Description=Start x11vnc at startup.
After=multi-user.target
[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/<user>/.vnc/passwd -rfbport 5900 -shared
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable x11vnc.service
sudo systemctl start x11vnc.service
四、检查VNC服务端口,若存在5900端口,说明服务启动成功
ss -tunlp | grep 5900