ubuntu 19.10 desktop 配置遠程vnc

需求:
有一臺ubuntu 19.10,已安裝圖形界面,現需開啓vnc遠程桌面。

分析:
由於ubuntu desktop 自帶的定製了的gnome桌面系統,在該桌面系統下vnc4server和tightvncserver等均不可直接使用。
實際上Ubuntu Desktop是有桌面共享功能的,如果是最小化安裝就需要單獨安裝它。
Ubuntu桌面共享使用的是vino。
Ubuntu桌面共享使用的是vino。
Ubuntu桌面共享使用的是vino。
在ubuntu默認的gnome環境下不要使用vnc4server和tightvncserver,使用vino。


解決:

1。開啓ssh,並允許root密碼登錄

apt install openssh-server ssh

vi /etc/ssh/sshd_config

UsePAM yes

PermitRootLogin yes

PasswordAuthentication yes

#修改以上配置

systemctl enable ssh && systemctl restart ssh

#此時可以用root 密碼登錄ssh


2。開啓屏幕共享

打開Settings --> Screen Sharing -->激活並設置密碼

圖片.png

#如果沒有Screen Sharing選項,可能是vino沒有安裝,嘗試apt install vino 安裝

#激活後,用netstat -tulp | grep 59,查看端口是否監聽590X

#如果正常,可以嘗試用vnc連接,可能會出現“no security type suitable for RFB3.3”的錯誤。第3步就是解決這個問題。

3。關閉加密

gsettings set org.gnome.Vino require-encryption false

#關閉加密,此時vnc能正常連接


4。開啓用戶自動登錄桌面

vino必須登錄後才能啓動,所以還要配置用戶自動登錄桌面環境

vi /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf

[Seat:*]
user-session=ubuntu
greeter-show-manual-login=true
allow-guest=false

#允許root登錄桌面環境

Autologin-user=root

#自動登錄的用戶


vi /etc/pam.d/gdm-autologin

#auth   required        pam_succeed_if.so user != root quiet_success

#註釋此行

vi /etc/pam.d/gdm-password

#auth   required        pam_succeed_if.so user != root quiet_success

#註釋此行


vi /etc/gdm3/custom.conf

[daemon]
# Uncomment the line below to force the login screen to use Xorg
#WaylandEnable=false

# Enabling automatic login
AutomaticLoginEnable = true
AutomaticLogin = root

#配置自動登錄


vi /root/.profile

#mesg n || true
tty -s && mesg n || true

#修改mesg這行爲tty


5。重啓測試


6。修改屏幕共享端口

默認是5900,但由於業務需要,改成5901

apt-get install dconf-editor

#安裝dconf-editor

登錄圖形界面,執行dconf-editor,依次選擇/org/gnome/desktop/remote-access/alternative-port 關閉默認值,手動修改爲5901;

有資料說要再Again Right Click on     alternative_port and click on Set as Default (this is important),但實際測試時這步會還原成5900,不清楚是否必要。

然後打開use-alternative-port,這步很重要。

參考:https://ubuntuforums.org/showthread.php?t=1297290

netstat 檢查端口是否修改,就可以用新端口登錄。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章