RHEL 6 下 VNC Server 的配置

Linux 可以通过使用 SSH 远程连接来进行控制,也可以在主机执行以下命令进行投射。

[root@localhost ~]# export DISPLAY=ipaddress:0 [root@localhost ~]# xhost +

这个命令要求 ipaddress 的机器装有 X Server(比如 Xmanager),但有时需要将远程整个的 Linux 桌面投射到本地,这时仍可通过安装配置 Xmanager 来实现。

本文主要介绍 VNC Server 的配置方法,需配置好 yum 源,文中的“主机”指安装 Linux 的机器。

1. 首先验证主机上是否安装 VNC Server,使用以下的命令[root@localhost ~]# yum list | grep vnctigervnc.x86_64 1.0.90-0.10.20100115svn3945.el6 @local tigervnc-server.x86_64 1.0.90-0.10.20100115svn3945.el6 @local

若没有,则

[root@localhost ~]# yum install "*vnc*"

2. 随后启动 VNC Server,这时会要求你输入两次进行连接的初始密码。[root@localhost ~]# vncserver You will require a password to access your desktops. Password: //输入密码 Verify: //再次输入密码 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这里要注意:每个用户都可以启动多个 VNC Server 远程桌面,它们用 ip 加端口号:ip:1、ip:2、ip:3 来标识区分,使用同一端口会使另外登录的用户自动退出。另,VNC Server 的大部分配置文件及日志文件都在用户 home 目录的.vnc 目录下。用户可以自定义启动号码如:[root@localhost ~]# vncserver :2 #注意:2前面一定要有空格。 A VNC server is already running as :2

3. Red Hat Linux 支持两种图形模式:KDE 模式和 gnome 模式。

你的 Redh Hat 使用的什么图形模式这个一般只有登录到图形界面查看一下才能知道,或者通过[root@localhost ~]# ps -aux | grep gnome这样的命令来判断。如果是 gnome 桌面,那么需要修改/root/.vnc/xstartup的配置文件。使用 vi 打开 xstartup 文件,如下:[root@localhost /]# cd /root/.vnc[root@localhost .vnc]# vi xstartup删除全部内容,然后添加如下内容:unset SESSION_MANAGERexec /etc/X11/xinit/xinitrc4. 重启动 VNC Server[root@localhost ~]# vncserver -kill :1Killing Xvnc process ID 21198[root@localhost ~]# vncserverNew ‘localhost.localdomain:1 (root)’ desktop is localhost.localdomain:1Starting applications specified in /root/.vnc/xstartupLog file is /root/.vnc/localhost.localdomain:1.log5. 在防火墙上打开 VNC Server 的监听端口VNC Server 用到了三个端口:5801、5901、6001。[root@localhost /]# cd /etc/sysconfig[root@localhost sysconfig]# vi iptables添加如下三行-A INPUT -m state –state NEW -m tcp -p tcp –dport 5801 -j ACCEPT-A INPUT -m state –state NEW -m tcp -p tcp –dport 5901 -j ACCEPT-A INPUT -m state –state NEW -m tcp -p tcp –dport 6001 -j ACCEPT注意,一定要在-A INPUT -j REJECT –reject-with icmp-host-prohibited的前面,否则不会生效。6. 重新启动 iptables。[root@localhost sysconfig]# /etc/rc.d/init.d/iptables restartFlushing firewall rules: [ OK ]Setting chains to policy ACCEPT: filter [ OK ]Unloading iptables modules: [ OK ]Applying iptables firewall rules: [ OK ]Loading additional iptables modules: ip_conntrack_netbios_ns ip_conntrack_ftp [ OK ]7. 在 Windows 机器上使用 VNC Viewer 连接 VNC Server下载 VNC Viewer,运行然后输入IP:5901,输入刚才设定的密码,进入 RHEL 桌面。650) this.width=650;” width=”342″ height=”133″ alt=”” src=”https://blufiles.storage.live.com/y1pXYz3gzMt_JKyddApwAN-e5h_PfhlkPxZAepMj_ryfG51fgBlcd4ZyAGRfafmwePxvE62LtPyWgk/rel-vnc1.jpg?psid=1″ title=”rel-vnc1″ />650) this.width=650;” width=”368″ height=”107″ alt=”” src=”https://blufiles.storage.live.com/y1pXYz3gzMt_JJV9nzCFAA80ViGhvqfKUQSxNIGWqjlsNjzK4Hre8gPpuZGM02ZrQRv6_2BhJwS_jg/rel-vnc2.jpg?psid=1″ title=”rel-vnc2″ />650) this.width=650;” width=”461″ height=”533″ alt=”” src=”https://blufiles.storage.live.com/y1p7Y5vFnF01huGZgQCI6nq0Udq0H23mys2RDXST6atoh94LjP6GFA8N1dX3xr1Oc17Kp5YMa4O0ZA/rel-vnc3.jpg?psid=1″ title=”rel-vnc3″ />

补充:

在VNCServer的一个问题

[root@mail01 .vnc]# vncserver :1xauth: (stdin):1: bad display name "CC:1" in "add" commandNew 'mail01:1 (root)' desktop is mail01:1Starting applications specified in /root/.vnc/xstartupLog file is /root/.vnc/mail01:1.log

原因:hostname不能被ping在/etc/hosts里加入CC(本环境服务器hostname叫CC)就可以了

[root@mail01 .vnc]# vi /etc/hosts127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 CC ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

文章摘自http://niye.name/archives/1138

可见内心底对旅行是多么的淡漠。

RHEL 6 下 VNC Server 的配置

相关文章:

你感兴趣的文章:

标签云: