CentOS 6安装和配置VNC


VNC是Linux上的一款非常优秀的远程控制工具软件,通常我们在Windows上面安装vnc客户端软件来远程访问Linux机器(Windows上常用的客户端RealVNC),要远程连接到Linux首先要确保Linux上面已经安装了VNC server,下面以CentOS 6为例来说明:

1. 检查是否已经安装了VNC server

[root@centos6 ~]# rpm -qa | grep vnc
tigervnc-1.0.90-0.17.20110314svn4359.el6.i686
gtk-vnc-0.3.10-3.el6.i686
tigervnc-server-1.0.90-0.17.20110314svn4359.el6.i686
gtk-vnc-python-0.3.10-3.el6.i686

如果上面的几个rpm包已经存在,说明VNC server已经安装好了,接下来跳转步骤3启动vncserver就可以了,否则执行步骤2

2. 安装VNC server

# yum install tigervnc
# yum install tigervnc-server

3. 启动vncserver

第一次启动vncserver需要输入密码两次

[root@centos6 mnt]# vncserver

You will require a password to access your desktops.

Password:
Verify:

New 'centos6.xman.org:1 (root)' desktop is centos6.xman.org:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/centos6.xman.org:1.log

可以看到已经生成了一个desktop:centos6.xman.org:1

接下来在VNC客户端输入上面的desktop就可以连接上Linux的desktop,如果发现连接不上,有可能是下面两个原因导致的:

(1) 本地windows的hosts文件中没有配置远程Linux的hostname,解决方案也很简单,只需要将desktop的hostname替换为IP地址或者在本地windows的hosts文件中添加相应的hostname与IP的映射关系即可

(2) 是由于Linux的防火墙阻止了,这时我们可以选择关闭防火墙或者将VNC的服务端口加入到Linux防火墙的信任列表

#关闭防火墙
# /sbin/service ipstables stop

如何将VNC server添加到Linux的防火墙信任列表,可以参见Linux防火墙策略配置。

相关内容