1、安装服务
sudo apt-get update
sudo apt-get install x11vnc
2、配置密码
x11vnc -storepasswd
3、启动服务
x11vnc -auth guess -once -loop -noxdamage -repeat -rfbauth ~/.vnc/passwd -rfbport 5900 -shared
也可以写个service
cat > /etc/systemd/system/vnc.service <<EOF
[Unit]
Description=vnc
After=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -auth guess -once -loop -noxdamage -repeat -rfbauth /root/.vnc/passwd -rfbport 5900 -shared
Restart=always
User=root
[Install]
WantedBy=default.target
EOF
#启动
service vnc start
#开机自启
systemctl enable vnc