centos下遠程桌面的設置及問題處理

這幾天在研究linux下遠程,現把這些資料記錄如下,資料是網絡上找來的

1.檢查VNC客戶端和服務器端是否已經安裝

執行如下命令:
rpm -q vnc vnc-server
假如返回類似如下信息,
[root@localhost likeshare]# rpm -q vnc vnc-server
vnc-4.1.2-14.el5_6.6
vnc-server-4.1.2-14.el5_6.6
則說明系統已經默認安裝了vnc服務器端(一般來說,CentOS系統都默認安裝了vnc server)。

如果沒有安裝vnc-server

可以按如下方式在線安裝

yum  install vnc vnc-server

確定vnc-server已經安裝

啓動vncserver

[root@localhost likeshare]# vncserver

New 'localhost:4 (likeshare)' desktop is localhost:4

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost:4.log

2. 修改VNC SERVER的窗口治理器

上面的啓動過程顯示vnc的配置文件和日誌文件存放在.vnc/這個文件下

編輯xstartup文件,使窗口管理器更好看

因爲默認的是twn有點愁

[root@localhost likeshare]# vi ~/.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&                    註釋掉這個#
gnome-session& #加上這行

#startkde #kde desktop #如果是用kde去掉這行前面的註釋號即可
如果有其他的用戶依次照照做就可以
3 在CentOS系統中將用戶名加入到配置文件中
使用如下命令編輯配置文件,添加帳戶信息:
vi /etc/sysconfig/vncservers
做如下修改

  1. #  
  2. # Uncomment the line below to start a VNC server on display :1  
  3. # as my 'myusername' (adjust this to your own). You will also  
  4. # need to set a VNC password; run 'man vncpasswd' to see how  
  5. # to do that.  
  6. #  
  7. # DO NOT RUN THIS SERVICE if your local area network is  
  8. # untrusted! For a secure way of using VNC, see  
  9. # lt;URL:http://www.uk.research.att.com/vnc/sshvnc.htmlamp;gt;.  
  10. VNCSERVERS="1:myusername" 
  11. VNCSERVERS="1:gavin 2:john" # use the method for more user  
  12. VNCSERVERS="2:root" 
  13. # VNCSERVERARGS[1]="-geometry 800x600"  
  14. VNCSERVERARGS[2]="-geometry 1024x768"  
這是我自己的配置文件

#VNCSERVERS="1: user1 2: user2 3: user3"
VNCSERVERS="2:root"
#VNCSERVERS=[2]="-geometry"

#VNCSERVERS=[3]="-geometry 1024x768"

VNCSERVERARGS[2]="-geometry 800x600"
#VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"
#VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"
在這裏有點不明白的是,我設置的登錄用戶是root

但是我用likeshare也是可以登錄的

不知道什麼原因,有時間測試下,

退出vi 按esc 然後:wq回車

啓動vncserver

3.啓動VNC服務

使用如下命令啓動VNC SERVER
sbin/service vncserver start
當顯示如下信息時,表示啓動成功:
Starting VNC server: 2:root  [ OK ]

啓動失敗有這麼幾個援引我自己遇到的。

1。配置文件有問題,像參數給的不正確,格式寫的有問題

我就是因爲VNCSERVERARGS[2]="-geometry 800x600"分辨率的x有問題的所以服務啓動出問題

多試試搞定

4、從VNC view登錄

在windows上安裝vnc view,然後輸入xxx.xxx.xxx.xxx:2,連接登錄,輸入密碼即可。備註:假如從vnc view登錄時,提示connection refused(10061),則是因爲linux防火牆的問題,登錄centos系統,選擇SystemPreferencesRemote Desktop,勾選sharing中的兩項,Security兩項不勾,點擊關閉,然後再重新用vnc view登錄即可

也可以用命令來設置防火牆如下:

vi /etc/sysconfig/iptables
找到以下的語句:

-A RH-Firewall-l-INPUT-j INPUT-j REJECT - reject-with icmp-host-prohibited

在此語句前面加上下面的內容:

-A Rh-Firewall-l-INPUT-m state -state NEW-m tcp-p tcp-dport 5900 -j ACCEPT





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