Ubuntu20.04 Desktop安裝tigervnc-server
一、准備
由於使用的是desktop版,默認為gnome桌面
二、安裝TigerVNC服務器
TigerVNC,是一個主動維護的高性能VNC服務器
sudo apt install tigervnc-standalone-server
三、修改配置文件
如果home目錄下沒有.vnc
目錄,新建目錄
touch $HOME/.vnc/xstartup
修改xstartup
, vim .vnc/xstartup
, 修改為以下內容:
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
/etc/X11/xinit/xinitrc
# Assume either Gnome or KDE will be started by default when installed
# We want to kill the session automatically in this case when user logs out. In case you modify
# /etc/X11/xinit/Xclients or ~/.Xclients yourself to achieve a different result, then you should
# be responsible to modify below code to avoid that your session will be automatically killed
if [ -e /usr/bin/gnome-session -o -e /usr/bin/startkde ]; then
vncserver -kill $DISPLAY
fi
修改xstartup
權限
chmod u+x xstartup
四、創建vnc端口
- 一定要加上
-localhost no
, 否則只能本地連接,不能實現遠程連接,那么vnc就毫無意義 - 關閉防火牆,否則可能無法連接
vncserver :1 -geometry 1920x1000 -depth 24 -localhost no