1.驗證是否已經安裝VNC,CentOS通常自帶
rpm –qa |grep vnc
若是結果爲:
tigervnc-server-1.0.90-0.17.20110314svn4359.el6.i686(不一樣版本的名稱不一樣)
說明已安裝
若是沒有安裝,可以使用命令:
rpm –ivh tigervnc-server-1.0.90-0.17.20110314svn4359.el6.i686.rpm
2.指定遠程桌面用戶
vi /etc/sysconfig/vncservers
在裏面添加
[root@muxiyuan ~]# vim /etc/sysconfig/vncservers
VNCSERVERS="1:root 2:root 3:root "
VNCSERVERARGS[1]="-geometry 1360x768 -alwaysshared -depth 16"
VNCSERVERARGS[2]="-geometry 1024x600 -alwaysshared -depth 16"
VNCSERVERARGS[3]="-geometry 800x600 -alwaysshared -depth 16"
3.添加密碼
vncpasswd
會出現輸入密碼的提示
4.關閉iptables或在該文件中加入特例
此處直接關閉
service iptables stop
或4.2
vi /etc/sysconfig/iptables 加上下面的內容:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5900:5903 -j ACCEPT
[root@localhost~]#/sbin/service iptables restartvim
5.新建一個 /root/.vnc/xstartup文件,權限爲755
內容爲:
#!/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 &
gnome-session &
6.啓動VNC
/sbin/service vncserver start
7.開機啓動VNCSERVER
chkconfig vncserver on
8.登陸時填寫192.168.10.10:1或2等(1或2爲桌面號)
9.中止vncserver
#vncserver -kill :1(1爲桌面號)centos