yum groupinstall desktop #如果不安裝,從客戶端登錄後可能是一片空白
yum install tigervnc-server
修改vncserver的配置文件:
vi /etc/sysconfig/vncservers VNCSERVERS="1:root 2:usera 3:userb" VNCSERVERARGS[1]="-geometry 1920x1080 -nolisten tcp "
注意此處不能有-localhost參數,否則只監聽本地端口,無法遠程連接.
設置vnc密碼
[root@testdb ~]# vncserver #或者使用vncpasswd 輸入vnc訪問密碼,會自動保存在/root/.vnc/passwd文件中。 [root@testdb ~]# vi /root/.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 & xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & twm & 將這個xstartup文件的最後一行修改爲“startkde &”,再重新啓動vncserver服務後就可以登陸到KDE桌面環境 將這個xstartup文件的最後一行修改爲“gnome-session &”,再重新啓動vncserver服務後就可以登陸到GNOME桌面環境
service vncserver restart chkconfig --level 35 vncserver on
檢查:
netstat -tlnp
如果存在59xx的端口,證明vncserver啓動成功。從遠端連接,"地址IP:port",即可成功看到桌面系統。
補充內容:
VNCSERVERARGS參數介紹-geometry 桌面分辨率,默認1024x768;-nohttpd 不監聽HTTP端口(58xx端口);-nolisten tcp 不監聽X端口(60xx端口);-localhost 只允許從本機訪問;-AlwaysShared 默認只同時允許一個vncviewer連接,此參數允許同時連多個vncviewer;-SecurityTypes None 登錄不需要密碼認證VncAuth默認值,要密碼認證。
如無必要,服務器不建議啓用vnc服務。