vncserver建立與客戶端連線

atlantisholic發表於2011-03-21

1. 確認伺服器端是否安裝了vncserver

Vnc相關依賴包

gtk-vnc-python-0.3.2-3.el5

vnc-server-4.1.2-14.el5

gtk-vnc-0.3.2-3.el5

vnc-4.1.2-14.el5

   [root@localhost: ~]#rpm -q gtk-vnc-python vnc-server gtk-vnc vnc

 

2. 建立VNCSERVER服務:
      [root@localhost /]# vncserver

You will require a password to access your desktops.

Password:     輸入vnc 連線密碼

Verify:       確認vnc密碼

xauth:  creating new authority file /root/.Xauthority

New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1

Creating default startup script. /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log

   檢視已經啟動的vncserver

      Ps –ef|grep vnc

 

3. 修改配置檔案,實現圖形化連線

      修改~/.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

         ……….

         ………..

4. 啟動對應的VNCSERVER,使用以下命令:

         Vncserver :1  --啟動埠號為5901vncserver

         Vncserver :2    --啟動埠號為5902vncserver

5. 關閉對應的VNCSERVER,使用以下命令:

  Vncserver –kill :1  --關閉埠號為5901vncserver

  Vncserver –kill :2  --關閉埠號為5902vncserver

6.修改vncserver的密碼:

         Vncpasswd

7.  VNCSERVER修改登入使用者的資訊

        [root@localhost: ~]#vi /etc/sysconfig/vncservers

# The VNCSERVERS variable is a list of display:user pairs.

# Uncomment the lines below to start a VNC server on display :2

# as my 'myusername' (adjust this to your own).  You will also

# need to set a VNC password; run 'man vncpasswd' to see how

# to do that.

#

# DO NOT RUN THIS SERVICE if your local area network is

# untrusted!  For a secure way of using VNC, see

# .

 

# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.

 

# Use "-nohttpd" to prevent web-based VNC clients connecting.

 

# Use "-localhost" to prevent remote VNC clients connecting except when

# doing so through a secure tunnel.  See the "-via" option in the

# `man vncviewer' manual page.

 

 VNCSERVERS="1:root 2:demo"     此處新增使用者

 VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"

#vncserver -geometry 800x600      設定vncserver的解析度
#vncserver -geometry 640x480     
設定vncserver的解析度

#vncserver -depth 8                  設定vncserver的色深
#vncserver -depth 16               
設定vncserver的色深

8.客戶端連線VNC伺服器:

a、在linux下,執行vncviewer命令即可,伺服器地址的寫法形如192.168.3.119:1
b
、在windows下,執行windows版本的vncviewer即可,用法與linux下相近。

c
、用瀏覽器(平臺無關),作為java applet來實現,以形如http://192.168.3.119:5801的方式來啟動    vnc 埠從5800 開始依次類推,一般會是58005900

 

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23071790/viewspace-690068/,如需轉載,請註明出處,否則將追究法律責任。

相關文章