centos安装vnc界面

2018年10月21日15:46:25 发表评论 1,560 views

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需要输入密码两次

centos安装vnc界面
[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
centos安装vnc界面

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

为了方便,可见将vncserver添加到开机启动的服务中,使用setup->System services, 选择vncserver保存即可

接下来在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防火墙策略配置。

为了系统的安全性考虑,最好不要关闭防火墙,我们可以把vnc的访问端口配置在/etc/sysconfig/iptablest的行人列表中

 

[root@centos6u2 ~]# vim /etc/sysconfig/iptables
# then add below line to this file
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5900:5910 -j ACCEPT

# restart iptables
[root@centos6u2 ~]# service iptables restart

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: