Ubuntu 20.04 VNC 安裝
發表於 : 2020年 12月 3日, 00:59
sudo apt-get update sudo apt-get upgrade Ubuntu 20.04 默認使用 gdm3,導致 VNC 工作異常(這邊案例就是設定檔設定完成沒有效果),需切換到lightdm Ubuntu 16.04 默認使用 lightdm 因此一般不需要調整 sudo apt install lightdm ## ubuntu 20.04 需用到 sudo dpkg-reconfigure lightdm ## 將配置切換到 lightdm 安裝 x11VNC: sudo apt-get install x11vnc -y 若未更新直接執行上面指令可能會出現error,解決方法: sudo apt-get update 設定連接的VNC密碼 sudo x11vnc -storepasswd /etc/x11vnc.pass setpasswd 需手工設置一下權限,默認設置的權限可能會導致其他用戶無法正常讀取 sudo chmod 755 /etc/x11vnc.pass rfbport 參數指定監聽端口,-forever 參數指定客戶端斷開後不要停止服務而是繼續等待下一次的連接請求 sudo x11vnc -auth guess -rfbauth /etc/x11vnc.pass -rfbport 5900 -forever -display :0 設置開機自動啟動 VNC 功能 sudo nano /etc/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 /etc/x11vnc.pass -rfbport 5900 -shared [Install] WantedBy=multi-user.target 配置完 systemd 後啟動服務 sudo systemctl daemon-reload sudo systemctl enable x11vnc sudo systemctl start x11vnc cd /etc/X11 sudo nano xorg.conf ## VNC-virsual montior Section "Device" Identifier "Configured Video Device" EndSection Section "Monitor" Identifier "Configured Monitor" EndSection Section "Screen" Identifier "Default Screen" Monitor "Configured Monitor" Device "Configured Video Device" SubSection "Display" Depth 24 Virtual 1920 1080 EndSubSection EndSection sudo reboot