本文共 2697 字,大约阅读时间需要 8 分钟。
1.首先查询是否安装VNC Server rpm -qa |grep vnc 如果有类似于: vnc-server- 的值返回说明已经安装了vnc-server 如果没有安装采用yum安装 yum -y install vnc 2.配置VNC用户如果以root登录的话,输入 vncpasswd Password: Verify: 设置root用户的VNC登录用户名和密码 3.配置vnc-server的配置文件 /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 # <URL:http://www.uk.research.att.com/archive/vnc/sshvnc.html>. # 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" # VNCSERVERS="2:myusername" # VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost" VNCSERVERARGS[1]="-geometry 800x600" 1.VNCSERVERS=后面可以支持多用户,以空格隔开。如: VNCSERVERS="1:myusername 15:otheruser"--->这里的1 和15是端口号,用于连接时的端口 2.VNCSERVERARGS后面的[]里面的数据要与VNCSERVERS后面对应用户的值要一致。好像不一致也没有关系 VNCSERVERARGS基本参数有: -geometry 桌面大小,缺省是1024x768 -nohttpd 不监听HTTP端口 -nolisten tcp 不监听X端口 -localhost 只允许从本机访问 -AlwaysShared 默认的, 同时只能有一个vncviewer连接(跟客户端配置也有关), 一旦第2个连上去, 第1个就被断开了. 此参数允许同时连多个vncviewer -SecurityTypes None登录不需要密码认证 VncAuth默认值,要密码认证 启动vncserver /sbin/nvcserver start 如果没有出错的话,就会启动vnc服务了 4.修改默认桌面设置 在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 & ---把这两行注释掉,加上 #exec startxfce4 gnome-session 重新启动vncserver netstat -antpl查看可以发现有三个端口在监听。 5901 5801 6001 这三个端口: 默认的, vnc 服务监听3个TCP端口 RFB(Remote FrameBuffer)协议 默认端口 : 5900 显示器号 HTTP协议默认端口 : 5800 显示器号 X协议 默认端口 : 6000 显示器号 vncserver使用的显示器编号默认从1开始, 依次使用, 也可以参数指定端口号 我们只需要RFB协议就可以了,所以我们把5800 6000这两种端口关掉。 需要修改/etc/sysconfig/vncservers 在参数后面加上: -nohttpd 不监听HTTP端口-nolisten tcp 不监听X端口
5. Windows登陆到VNC Server
(1).从IE登录 直接从IE浏览器中输入如下地址: http://xxx.xxx.xxx.xxx:5801 输入密码即可使用。 (2).从VNC view登录 在windows上安装vnc view,然后输入xxx.xxx.xxx.xxx:1,连接登录,输入密码即可。 备注:如果从vnc view登录时,提示connection refused(10061),则是因为linux防火墙的问题,登录centos系统,选择 System-->Preferences-->Remote Desktop,勾选sharing中的两项,Security两项不勾,点击关闭,然后再重新用vnc view登录即可。转载地址:http://jvwvf.baihongyu.com/