系統環境
- 服務端:Ubuntu 18.04 Server LTS
- 客戶端:Windows10
- 客戶端VNC-Viewer 6.20下載地址:https://www.realvnc.com/en/connect/download/viewer/
安裝桌面環境
本實驗中安裝的系統沒有安裝桌面環境,我們需要自己安裝,如果已經安裝桌面了清跳過這一步。
我們可Ubuntu提供了許多桌面環境,可以選擇自己喜歡的桌面環境,在這里選擇安裝Xfce4桌面:
bpang@ubuntu1804:~$ sudo apt install xfce4*
安裝VNC Server
安裝倉庫提供的vnc4server:
bpang@ubuntu1804:~$ sudo apt install vnc4server
運行vncserver命令創建一個初始配置并設置密碼:
bpang@ubuntu1804:~$ vncserver
You will require a password to access your desktops.
Password:
Verify:
New 'ubuntu1804:1 (bpang)' desktop is ubuntu1804:1
Creating default startup script /home/bpang/.vnc/xstartup
Starting applications specified in /home/bpang/.vnc/xstartup
Log file is /home/bpang/.vnc/ubuntu1804:1.log
然后停止vncserver服務:
bpang@ubuntu1804:~$ vncserver -kill :1
Killing Xvnc4 process ID 10260
配置VNC Server
編輯用戶家目錄下面的.vnc/xstartup文件
bpang@ubuntu1804:~$ vim .vnc/xstartup
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
startxfce4 &
設置vncserver開機啟動
在/etc/init.d文件夾下面創建vncserver文件,export USER=’bpang’改成自己的用戶名
bpang@ubuntu1804:~$ sudo vim /etc/init.d/vncserver
#!/bin/bash
export USER='bpang'
eval cd ~$USER
case "$1" in
start)
su $USER -c '/usr/bin/vncserver :1'
echo "Starting VNC server for $USER "
;;
stop)
su $USER -c '/usr/bin/vncserver -kill :1'
echo "vncserver stopped"
;;
*)
echo "Usage: /etc/init.d/vncserver {start|stop}"
exit 1
;;
esac
exit 0
給vncserver添加執行權限
bpang@ubuntu1804:~$ sudo chmod +x /etc/init.d/vncserver
開機啟動設置
bpang@ubuntu1804:~$ sudo update-rc.d vncserver defaults
bpang@ubuntu1804:~$ sudo service vncserver start
客戶端遠程連接測試
在windows10客戶端打開VNC Viewer,輸入地址和回話端口號:
總結
如果需要將VNC服務器配置為多個用戶啟動顯示,請使用vncserver命令創建初始配置并設置密碼,然后使用其他端口創建新的服務文件。
本文為企業推廣,本網站不做任何建議,僅提供參考,作為信息展示!
推薦閱讀:上海生活網
網友評論
請登錄后進行評論|
0條評論
請文明發言,還可以輸入140字
您的評論已經發表成功,請等候審核
小提示:您要為您發表的言論后果負責,請各位遵守法紀注意語言文明