一、Redhat上VNC Server配置
前提:连接到互联网,将使用yum在线安装VNC服务器
1.安装 TigerVNC Server
# yum searchtigervnc-server
返回大概如下内容:
tigervnc-server.x86_64: A TigerVNC Server
tigervnc-server-applet.noarch: Java TigerVNC Viewer applet for TigerVNC Server
tigervnc-server-module.x86._64: TigerVNC Mode to Xorg
第一行即是我们要安装的VNS服务器,第二行是客户端,执行
# yum installtigervnc-server.x86_64 或者yum install tigervnc* 回车后会有一次安装确认,输入y后回车即可安装,安装完毕 命令行输入光标,执行 # vncserver 会提示输入验证密码,至少6位,该密码是客户端连接时用到的。 2.配置图形界面 修改配置文件,激活图形界面,执行命令: # vi /root/.vnc/xstartup 注释掉这行 #twm & // 注释该行 末尾增加一行 gnome-session & // 增加该行 保存退出 3.启动VNC服务 执行命令 # /etc/init.d/vncserver start 或 # service vncserver start 启动后提示: Starting VNC server: no displays configured [FAILED] 解决方法: 执行命令 # vim /etc/sysconfig/vncservers 修改最后两行如: VNCSERVERS="1:root" VNCSERVERARGS[1]="-geometry 1024x768" 说明: 第一行为服务配置,当前只配置了一个VNC服务,使用用户root启动,如果还需要使用其他用户登陆,可以修改VNCSERVERS的值如:“1:root 2:tiger”(tiger为系统另一存在用户)。第二行可以注释,是配置窗口分辨率的,需要去掉后面的-localhost VNC Server随系统自动启动 执行命令 # sudo chkconfig --level 345 vncserver on 4.停止VNC服务 执行命令 # /etc/init.d/vncserver stop 或 # service vncserver stop 二、Windows借助VNC Viewer访问Linux 首先安装RealVNC,从互联网下载获得 开始 - Run VNC Viewer,输入IP地址,后面的:1代表使用root用户登陆,在RH上配置的1:root,如果想使用其他用户登陆则调整冒号后的数字即可,密码就是先前配置的。 格式:IP地址:1 解决连接不上问题的方法 执行命令,查看VNC监听的端口是什么,在防火墙中开放端口即可或者停止防火墙 # netstat -ntupl|grep vnc 返回列表如: 1. tcp 0 0 0.0.0.0:59010.0.0.0:* LISTEN 4411/Xvnc 2. tcp 0 0 0.0.0.0:60010.0.0.0:* LISTEN 4411/Xvnc 3. tcp 0 0 :::6001 :::* LISTEN 4411/Xvnc 修改防火墙配置文件,开放5901端口即可 # vi /etc/sysconfig/iptables 可以复制22端口一行,黏贴修改即可,重新启动防火墙服务 # service iptables restart 完整命令 [iyunv@localhost ~]#yum install tigervnc* ======》yum在线安装软件 已加载插件:fastestmirror, product-id, refresh-packagekit, subscription-manager This system isnot registered to Red Hat Subscription Management. You can usesubscription-manager to register. 设置安装进程 Loading mirrorspeeds from cached hostfile 解决依赖关系 --> 执行事务检查 ---> Packagetigervnc.x86_64 0:1.1.0-16.el6.centoswill be 安装 ---> Packagetigervnc-server.x86_64 0:1.1.0-16.el6.centoswill be 安装 ---> Packagetigervnc-server-applet.noarch 0:1.1.0-16.el6.centoswill be 安装 ---> Packagetigervnc-server-module.x86_64 0:1.1.0-16.el6.centoswill be 安装 --> 完成依赖关系计算 依赖关系解决 ============================================== 软件包 架构 版本 仓库 大小 ================================================================ 正在安装: tigervnc x86_64 1.1.0-16.el6.centos updates 185 k tigervnc-server x86_64 1.1.0-16.el6.centos updates 1.0 M tigervnc-server-applet noarch 1.1.0-16.el6.centos updates 108 k tigervnc-server-module x86_64 1.1.0-16.el6.centos updates 213 k 事务概要 ============================================================== Install 4 Package(s) 总下载量:1.5 M Installed size:3.7 M 确定吗?[y/N]:y 下载软件包: (1/4): tigervnc-1.1.0-16.el6.centos.x86_64.rpm | 185 kB 00:01 (2/4):tigervnc-server-1.1.0-16.el6.centos.x86_64.rpm | 1.0 MB 00:03 (3/4):tigervnc-server-applet-1.1.0-16.el6.centos.noarch| 108 kB 00:00 (4/4):tigervnc-server-module-1.1.0-16.el6.centos.x86_64| 213 kB 00:00 -------------------------------------------------------------------------------- 总计 228kB/s | 1.5 MB 00:06 运行 rpm_check_debug 执行事务测试 事务测试成功 执行事务 正在安装 : tigervnc-server-1.1.0-16.el6.centos.x86_64 1/4 正在安装 : tigervnc-server-applet-1.1.0-16.el6.centos.noarch 2/4 正在安装 : tigervnc-1.1.0-16.el6.centos.x86_64 3/4 正在安装 : tigervnc-server-module-1.1.0-16.el6.centos.x86_64 4/4 Verifying : tigervnc-server-module-1.1.0-16.el6.centos.x86_64 1/4 Verifying : tigervnc-server-1.1.0-16.el6.centos.x86_64 2/4 Verifying : tigervnc-server-applet-1.1.0-16.el6.centos.noarch 3/4 Verifying : tigervnc-1.1.0-16.el6.centos.x86_64 4/4 已安装: tigervnc.x86_64 0:1.1.0-16.el6.centos tigervnc-server.x86_64 0:1.1.0-16.el6.centos tigervnc-server-applet.noarch 0:1.1.0-16.el6.centos tigervnc-server-module.x86_64 0:1.1.0-16.el6.centos 完毕! [iyunv@localhost ~]# vncserver ======》设置登录密码,输入验证密码,至少6位,该密码是客户端连接时用到的 You will requirea password to access your desktops. Password:1103324414 Verify:1103324414 xauth: creating new authority file /root/.Xauthority New'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1 Creating defaultstartup script /root/.vnc/xstartup Startingapplications specified in /root/.vnc/xstartup Log file is/root/.vnc/localhost.localdomain:1.log [iyunv@localhost ~]# vim /root/.vnc/xstartup =====》开启图形界面 #!/bin/sh [ -r/etc/sysconfig/i18n ] && . /etc/sysconfig/i18n export LANG export SYSFONT vncconfig-iconic & unsetSESSION_MANAGER unsetDBUS_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 -solidgrey xterm -geometry80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & #twm & gnome-session & ".vnc/xstartup"30L, 671C 已写入 [iyunv@localhost~]# service vncserver status Xvnc (pid 3968) 正在运行... [iyunv@localhost~]# service vncserver restart 关闭 VNC 服务器:[失败] 正在启动 VNC 服务器:nodisplays configured [失败] [iyunv@localhost ~]# service vncserver stop 关闭 VNC 服务器:[失败] [iyunv@localhost~]# service vncserver start 正在启动 VNC 服务器:nodisplays configured [失败] [iyunv@localhost ~]# vim /etc/sysconfig/vncservers ======》编辑登录用户,修改分辨率
# The VNCSERVERSvariable is a list of display:user pairs. # # Uncomment thelines below to start a VNC server on display :2 # as my'myusername' (adjust this to your own). You will also # need to set aVNC password; run 'man vncpasswd' to see how # to do that. # # DO NOT RUNTHIS SERVICE if your local area network is #untrusted! For a secure way of usingVNC, see this URL:
# Use"-nolisten tcp" to prevent X connections to your VNC server via TCP.
# Use"-localhost" to prevent remote VNC clients connecting except when # doing sothrough a secure tunnel. See the"-via" option in the # `manvncviewer' manual page.
VNCSERVERS="1:root" # VNCSERVERARGS[1]="-geometry 1024x768 " "/etc/sysconfig/vncservers"19L, 745C 已写入 [iyunv@localhost ~]# chkconfig --level 345 vncserver on========》开机启动 [iyunv@localhost ~]# /etc/init.d/vncserver restart ====》注意启动失败的提示 关闭 VNC 服务器:[确定] 正在启动 VNC 服务器:1:root Warning:localhost.localdomain:1 is taken because of /tmp/.X1-lock Remove this fileif there is no X server localhost.localdomain:1 A VNC server isalready running as :1 [失败] [iyunv@localhost ~]# cd/tmp/ ======?进入到失败提示的目录 [iyunv@localhost tmp]# ls keyring-I5r3Uo pulse-Bj8Ca1cagmpn virtual-root.4aswhI VMwareDnD keyring-lU5Juj pulse-hvB4wFMaeoLd virtual-root.HVHL6f vmware-root orbit-gdm ssh-aICQHU3879 virtual-root.ijnIyc vmware-root-860006770 orbit-root uptime.sh virtual-root.wPiLgI [iyunv@localhosttmp]# ls -al 总用量 92 drwxrwxrwt. 20root root 4096 7月 15 09:29 . dr-xr-xr-x. 27root root 4096 7月 15 09:14 .. drwx------. 2 root root 4096 7月 15 09:15 .esd-0 drwx------. 2 sandu sandu 4096 5月 5 17:23 .esd-500 drwxrwxrwt. 2 root root 4096 7月 15 09:24 .ICE-unix drwx------. 2 root root 4096 7月 15 09:24 keyring-I5r3Uo drwx------. 2 root root 4096 7月 15 09:15 keyring-lU5Juj drwx------. 2 gdm gdm 4096 7月 15 09:15 orbit-gdm drwx------. 2 root root 4096 7月 15 09:29 orbit-root drwx------. 2 gdm gdm 4096 7月 15 09:15 pulse-Bj8Ca1cagmpn drwx------. 2 root root 4096 7月 15 09:24 pulse-hvB4wFMaeoLd drwx------. 2 root root 4096 7月 15 09:21 ssh-aICQHU3879 -rw-r--r--. 1 root root 235 6月 8 09:39 uptime.sh drwx------. 2 root root 4096 7月 15 09:24 virtual-root.4aswhI drwx------. 2 root root 4096 7月 15 09:15 virtual-root.HVHL6f drwx------. 2 root root 4096 6月 9 08:28 virtual-root.ijnIyc drwx------. 2 root root 4096 6月 24 08:54 virtual-root.wPiLgI drwxrwxrwt. 2 root root 4096 6月 9 08:26 VMwareDnD drwx------. 2 root root 4096 7月 15 09:24 vmware-root drwx------. 2 root lp 4096 6月 9 08:25 vmware-root-860006770 -r--r--r--. 1 root root 11 7月 15 09:14 .X0-lock drwxrwxrwt. 2 root root 4096 7月 15 09:24 .X11-unix -r--r--r--. 1 root root 11 7月 15 09:24 .X1-lock [iyunv@localhost tmp]# rm -rf .X1-lock ======》删除启动失败提示的文件 [iyunv@localhost tmp]# /etc/init.d/vncserver start ======》启动还是失败,继续删除提示的文件 正在启动 VNC 服务器:1:root Warning:localhost.localdomain:1 is taken because of /tmp/.X11-unix/X1 Remove this fileif there is no X server localhost.localdomain:1 A VNC server isalready running as :1 [失败] [iyunv@localhosttmp]# ls -al 总用量 88 drwxrwxrwt. 20root root 4096 7月 15 09:34 . dr-xr-xr-x. 27root root 4096 7月 15 09:14 .. drwx------. 2 root root 4096 7月 15 09:15 .esd-0 drwx------. 2 sandu sandu 4096 5月 5 17:23 .esd-500 drwxrwxrwt. 2 root root 4096 7月 15 09:24 .ICE-unix drwx------. 2 root root 4096 7月 15 09:24 keyring-I5r3Uo drwx------. 2 root root 4096 7月 15 09:15 keyring-lU5Juj drwx------. 2 gdm gdm 4096 7月 15 09:15 orbit-gdm drwx------. 2 root root 4096 7月 15 09:29 orbit-root drwx------. 2 gdm gdm 4096 7月 15 09:15 pulse-Bj8Ca1cagmpn drwx------. 2 root root 4096 7月 15 09:24 pulse-hvB4wFMaeoLd drwx------. 2 root root 4096 7月 15 09:21 ssh-aICQHU3879 -rw-r--r--. 1 root root 235 6月 8 09:39 uptime.sh drwx------. 2 root root 4096 7月 15 09:24 virtual-root.4aswhI drwx------. 2 root root 4096 7月 15 09:15 virtual-root.HVHL6f drwx------. 2 root root 4096 6月 9 08:28 virtual-root.ijnIyc drwx------. 2 root root 4096 6月 24 08:54 virtual-root.wPiLgI drwxrwxrwt. 2 root root 4096 6月 9 08:26 VMwareDnD drwx------. 2 root root 4096 7月 15 09:24 vmware-root drwx------. 2 root lp 4096 6月 9 08:25 vmware-root-860006770 -r--r--r--. 1 root root 11 7月 15 09:14 .X0-lock drwxrwxrwt. 2 root root 4096 7月 15 09:24 .X11-unix [iyunv@localhost tmp]# rm -rf .X* =====》删除提示的文件 [iyunv@localhost tmp]# ls -al 总用量 80 drwxrwxrwt. 19root root 4096 7月 15 09:34 . dr-xr-xr-x. 27root root 4096 7月 15 09:14 .. drwx------. 2 root root 4096 7月 15 09:15 .esd-0 drwx------. 2 sandu sandu 4096 5月 5 17:23 .esd-500 drwxrwxrwt. 2 root root 4096 7月 15 09:24 .ICE-unix drwx------. 2 root root 4096 7月 15 09:24 keyring-I5r3Uo drwx------. 2 root root 4096 7月 15 09:15 keyring-lU5Juj drwx------. 2 gdm gdm 4096 7月 15 09:15 orbit-gdm drwx------. 2 root root 4096 7月 15 09:29 orbit-root drwx------. 2 gdm gdm 4096 7月 15 09:15 pulse-Bj8Ca1cagmpn drwx------. 2 root root 4096 7月 15 09:24 pulse-hvB4wFMaeoLd drwx------. 2 root root 4096 7月 15 09:21 ssh-aICQHU3879 -rw-r--r--. 1 root root 235 6月 8 09:39 uptime.sh drwx------. 2 root root 4096 7月 15 09:24 virtual-root.4aswhI drwx------. 2 root root 4096 7月 15 09:15 virtual-root.HVHL6f drwx------. 2 root root 4096 6月 9 08:28 virtual-root.ijnIyc drwx------. 2 root root 4096 6月 24 08:54 virtual-root.wPiLgI drwxrwxrwt. 2 root root 4096 6月 9 08:26 VMwareDnD drwx------. 2 root root 4096 7月 15 09:24 vmware-root drwx------. 2 root lp 4096 6月 9 08:25 vmware-root-860006770 [iyunv@localhost tmp]# /etc/init.d/vncserver start =====》正常启动 正在启动 VNC 服务器:1:root New'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1 Startingapplications specified in /root/.vnc/xstartup Log file is/root/.vnc/localhost.localdomain:1.log [确定] [iyunv@localhosttmp]# cd [iyunv@localhost ~]# netstat -tulnp | grep vnc ======》查看服务侦听的端口 tcp 0 00.0.0.0:5801 0.0.0.0:* LISTEN 4858/Xvnc tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 4858/Xvnc tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 4858/Xvnc tcp 0 0 :::6001 :::* LISTEN 4858/Xvnc [iyunv@localhost ~]# service iptables stop ======》停用防火墙或者修改防火墙配置使服务侦听的端口放行 iptables:将链设置为政策 ACCEPT:filter [确定] iptables:清除防火墙规则:[确定] iptables:正在卸载模块:[确定] [iyunv@localhost~]# yum search tigervnc-server 已加载插件:fastestmirror, product-id, refresh-packagekit, subscription-manager This system isnot registered to Red Hat Subscription Management. You can usesubscription-manager to register. Loading mirrorspeeds from cached hostfile =========================================N/S Matched: tigervnc-server ========================================== tigervnc-server.x86_64: A TigerVNC server tigervnc-server-applet.noarch: Java TigerVNC viewer applet for TigerVNC server tigervnc-server-module.x86_64: TigerVNC module to Xorg
Name and summary matches only, use"search all" for everything.
桌面登录:
格式:“IP地址:1” 若未出现下面这个界面或者有各种各样的错误提示,一般是linux系统防火墙的问题,按照上面的所说修改防火墙配置即可
输入配置的密码
|