- 安装VNC服务端
- [root@rhel6 ~]# rpm -q tigervnc-server
- tigervnc-server-1.0.90-0.17.20110314svn4359.el6.x86_64
- 启动VNC服务
- [root@rhel6 ~]# vncserver #第一次启动display :1(第一张虚拟纸,依次类推),可通过vncserver :2 启动display:2
- New 'rhel6.xfcy.org:1 (root)' desktop is rhel6.xfcy.org:1
- Starting applications specified in /root/.vnc/xstartup
- Log file is /root/.vnc/rhel6.xfcy.org:1.log
- [root@rhel6 ~]# /etc/init.d/vncserver status
- Xvnc (pid 2182) is running...
- 修改VNC Server配置文件
- [root@rhel6 ~]# cat /etc/sysconfig/vncservers #启动vncserver后才生成
- # 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 this URL:
- # http://kbase.redhat.com/faq/docs/DOC-7028
- # Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
- # 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="2:myusername"
- # VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"
- VNCSERVERS="2:xfcy 3:root" #设置在vncserver启动2个display,且display:2,:3的用户权限分别为xfcy,root
- VNCSERVERARGS[2]="-geometry 800x600"
- VNCSERVERARGS[3]="-geometry 800x600 -localhost" #设置display:2的分辨率为800×600且只监听本地
- 设置VNC密码(保存在~/.vnc/passwd中),同时自动生成~/.vnc/xstartup(在每次启动VNC服务时候,都会读取该文件中的配置信息)
- [root@rhel6 ~]# vncpasswd
- Password:
- Verify:
- 修改xstartup配置文件
- [root@rhel6 ~]# cat ~/.vnc/xstartup
- #!/bin/sh
- [ -r /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
- export LANG
- export SYSFONT
- vncconfig -iconic &
- unset SESSION_MANAGER
- unset DBUS_SESSION_BUS_ADDRESS
- OS=`uname -s`
- if [ $OS = 'Linux' ]; then
- case "$WINDOWMANAGER" in
- *gnome*)
- if [ -e /etc/SuSE-release ]; then
- PATH=$PATH:/opt/gnome/bin
- export PATH
- fi
- ;;
- esac
- fi
- if [ -x /etc/X11/xinit/xinitrc ]; then
- exec /etc/X11/xinit/xinitrc
- fi
- if [ -f /etc/X11/xinit/xinitrc ]; then
- exec sh /etc/X11/xinit/xinitrc
- fi
- [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
- xsetroot -solid grey
- #xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & #注释掉这两行避免出现黑屏
- #twm &
- gnome-session & #登录到GNOME桌面环境
- #startkde & #登录到KDE桌面环境
- 配置Display:2(即用户权限为xfcy的共享桌面,配置方法同上)
- [root@rhel6 .vnc]# su - xfcy #必须在对应的用户下设置密码
- [xfcy@rhel6 ~]$ vncserver :2
- You will require a password to access your desktops.
- Password:
- Verify:
- New 'rhel6.xfcy.org:2 (xfcy)' desktop is rhel6.xfcy.org:2
- Creating default startup script /home/xfcy/.vnc/xstartup
- Starting applications specified in /home/xfcy/.vnc/xstartup
- Log file is /home/xfcy/.vnc/rhel6.xfcy.org:2.log
- [xfcy@rhel6 ~]$ vi .vnc/xstartup
- #!/bin/sh
- [ -r /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
- export LANG
- export SYSFONT
- vncconfig -iconic &
- unset SESSION_MANAGER
- unset DBUS_SESSION_BUS_ADDRESS
- OS=`uname -s`
- if [ $OS = 'Linux' ]; then
- case "$WINDOWMANAGER" in
- *gnome*)
- if [ -e /etc/SuSE-release ]; then
- PATH=$PATH:/opt/gnome/bin
- export PATH
- fi
- ;;
- esac
- fi
- if [ -x /etc/X11/xinit/xinitrc ]; then
- exec /etc/X11/xinit/xinitrc
- fi
- if [ -f /etc/X11/xinit/xinitrc ]; then
- exec sh /etc/X11/xinit/xinitrc
- fi
- [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
- xsetroot -solid grey
- #xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
- #twm &
- gnome-session &
- 重启VNC Server服务
- [root@rhel6 ~]# /etc/init.d/vncserver restart
- Shutting down VNC server: 2:xfcy 3:root [ OK ]
- Starting VNC server: 2:xfcy
- New 'rhel6.xfcy.org:2 (xfcy)' desktop is rhel6.xfcy.org:2
- Starting applications specified in /home/xfcy/.vnc/xstartup
- Log file is /home/xfcy/.vnc/rhel6.xfcy.org:2.log
- 3:root
- New 'rhel6.xfcy.org:3 (root)' desktop is rhel6.xfcy.org:3
- Starting applications specified in /root/.vnc/xstartup
- Log file is /root/.vnc/rhel6.xfcy.org:3.log
- [ OK ]
- [root@rhel6 .vnc]# netstat -lntp | grep 590 #VNC server监听的端口从5900开始,display :1的监听5901,display :2监听5902,以此类推
- tcp 0 0 0.0.0.0:5902 0.0.0.0:* LISTEN 3567/Xvnc
- tcp 0 0 127.0.0.1:5903 0.0.0.0:* LISTEN 3649/Xvnc
- 客户端访问
- [root@rhel5 ~]# vncviewer 192.168.1.119:3
- VNC Viewer Free Edition 4.1.2 for X - built Jan 26 2009 11:52:08
- Copyright (C) 2002-2005 RealVNC Ltd.
- See http://www.realvnc.com for information on VNC.
- Sun Nov 18 23:17:16 2012
- CConn: connected to host 192.168.1.119 port 5903
- CConnection: Server supports RFB protocol version 3.8
- CConnection: Using RFB protocol version 3.8
- Sun Nov 18 23:17:18 2012
- TXImage: Using default colormap and visual, TrueColor, depth 16.
- CConn: Using pixel format depth 6 (8bpp) rgb222
- CConn: Using ZRLE encoding
- Sun Nov 18 23:17:21 2012
- CConn: Throughput 20476 kbit/s - changing to hextile encoding
- CConn: Throughput 20476 kbit/s - changing to full colour
- CConn: Using pixel format depth 16 (16bpp) little-endian rgb565
- CConn: Using hextile encoding
- 通过SSH加密VNC的远程连接
- [root@rhel5 ~]# vncviewer -via 192.168.1.119 :2
- VNC Viewer Free Edition 4.1.2 for X - built Jan 26 2009 11:52:08
- Copyright (C) 2002-2005 RealVNC Ltd.
- See http://www.realvnc.com for information on VNC.
- The authenticity of host 'rhel6 (192.168.1.119)' can't be established.
- RSA key fingerprint is 1a:cf:92:de:28:7d:f2:e0:e8:e6:ad:f1:7c:40:6a:67.
- Are you sure you want to continue connecting (yes/no)? yes
- Warning: Permanently added 'rhel6' (RSA) to the list of known hosts.
- root@rhel6's password:
- Tue Nov 20 01:12:37 2012
- CConn: connected to host localhost port 5599
- CConnection: Server supports RFB protocol version 3.8
- CConnection: Using RFB protocol version 3.8
- Tue Nov 20 01:12:39 2012
- TXImage: Using default colormap and visual, TrueColor, depth 16.
- CConn: Using pixel format depth 6 (8bpp) rgb222
- CConn: Using ZRLE encoding
- Tue Nov 20 01:12:41 2012
- CConn: Throughput 20588 kbit/s - changing to hextile encoding
- CConn: Throughput 20588 kbit/s - changing to full colour
- CConn: Using pixel format depth 16 (16bpp) little-endian rgb565
- CConn: Using hextile encoding
- 关闭已启用的display:2
- [xfcy@rhel6 ~]$ vncserver -kill :2 #必须以相应的用户进行操作
- Killing Xvnc process ID 3567
- Xvnc seems to be deadlocked. Kill the process manually and then re-run
- /usr/bin/vncserver -kill :2
- to clean up the socket files.
- [root@rhel6 ~]# netstat -lntp | grep 590
- tcp 0 0 127.0.0.1:5903 0.0.0.0:* LISTEN 6585/Xvnc
- 附:AIX上部署VNC Server
- 一.安装VNC
- # rpm -ivh vnc-3.3.3r2-6.aix5.1.ppc.rpm
- vnc ##################################################
- # rpm -ql vnc
- /opt/freeware/bin/Xvnc
- /opt/freeware/bin/vncconnect
- /opt/freeware/bin/vncpasswd
- /opt/freeware/bin/vncserver
- /opt/freeware/bin/vncviewer
- /opt/freeware/doc/vnc-3.3.3r2
- /opt/freeware/doc/vnc-3.3.3r2/LICENCE.TXT
- /opt/freeware/doc/vnc-3.3.3r2/README
- /opt/freeware/share/vnc/classes
- /opt/freeware/share/vnc/classes/DesCipher.class
- /opt/freeware/share/vnc/classes/animatedMemoryImageSource.class
- /opt/freeware/share/vnc/classes/authenticationPanel.class
- /opt/freeware/share/vnc/classes/clipboardFrame.class
- /opt/freeware/share/vnc/classes/index.vnc
- /opt/freeware/share/vnc/classes/optionsFrame.class
- /opt/freeware/share/vnc/classes/rfbProto.class
- /opt/freeware/share/vnc/classes/shared.vnc
- /opt/freeware/share/vnc/classes/vncCanvas.class
- /opt/freeware/share/vnc/classes/vncviewer.class
- /opt/freeware/share/vnc/classes/vncviewer.jar
- /opt/freeware/vnc
- /usr/lpp/X11/bin/Xvnc
- /usr/lpp/X11/bin/vncconnect
- /usr/lpp/X11/bin/vncpasswd
- /usr/lpp/X11/bin/vncserver
- /usr/lpp/X11/bin/vncviewer
- 二.编辑配置文件:/opt/freeware/bin/vncserver
- 1.修改前:
- # $cmd .= " -fp /usr/lib/X11/fonts/,/usr/lib/X11/fonts/misc/,/usr/lib/X11/fonts/75dpi/";
- 修改后:(去掉注释,即加入了fonts)
- $cmd .= " -fp /usr/lib/X11/fonts/,/usr/lib/X11/fonts/misc/,/usr/lib/X11/fonts/75dpi/";
- $cmd .= " -ac -fp /usr/lib/X11/fonts/,/usr/lib/X11/fonts/misc/,/usr/lib/X11/fonts/75dpi/"; (若出现灰屏则设置为此)
- 2.修改前:
- $vncClasses = "/usr/local/vnc/classes";
- 修改后:
- $vncClasses = "/opt/freeware/vnc/classes";
- # cat /opt/freeware/bin/vncserver | egrep "font|vncClasses" | grep -v ^#
- $vncClasses = "/opt/freeware/vnc/classes";
- $cmd .= " -fp /usr/lib/X11/fonts/,/usr/lib/X11/fonts/misc/,/usr/lib/X11/fonts/75dpi/,/usr/lib/X11/fonts/100dpi/,/usr/lib/X11/fonts/ibm850/,/usr/lib/X11/fonts/Type1/";
- 三.如果要使用CDE界面(AIX下的XWindow,类似于Redhat的GNOME)
- # vi ~/.vnc/xstartup
- #!/bin/sh
- xrdb $HOME/.Xresources
- xsetroot -solid grey
- xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
- # twm & #注释掉原来的配置
- /usr/dt/bin/dtsession & #添加CDE界面的session
- 四.启动vncserver
- # su oracle
- $ vncserver
- You will require a password to access your desktops.
- Password:
- Verify:
- New 'X' desktop is fjkf:1
- Creating default startup script /home/oracle/.vnc/xstartup
- Starting applications specified in /home/oracle/.vnc/xstartup
- Log file is /home/oracle/.vnc/fjkf:1.log