configRemoteDesktop.sh 911 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash
  2. sudo apt update
  3. sudo apt install lightdm
  4. sudo apt install x11vnc
  5. # 配置访问密码
  6. sudo x11vnc -storepasswd /etc/x11vnc.pass
  7. # 配置文件权限,默认的权限导致其他用户可能无法正常使用
  8. sudo chmod 755 /etc/x11vnc.pass
  9. echo "Create service"
  10. cat > /lib/systemd/system/x11vnc.service << EOF
  11. [Unit]
  12. Description=Start x11vnc at startup.
  13. After=network-online.target
  14. [Service]
  15. Type=simple
  16. ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc.pass -rfbport 5900 -shared -display :0
  17. ExecStop=/bin/kill -TERM $MAINPID
  18. ExecReload=/bin/kill -HUP $MAINPID
  19. KillMode=control-group
  20. Restart=on-failure
  21. [Install]
  22. WantedBy=graphical.target
  23. EOF
  24. echo "Configure firewall"
  25. sudo ufw allow 5900
  26. echo "Configure Services"
  27. sudo systemctl daemon-reload
  28. sudo systemctl enable x11vnc.service
  29. echo "Ready to reboot system..."
  30. sleep 5s
  31. sudo shutdown -r now