centos配置VNC

在CentOS系统安装的时候,我们应该对VNC做好配置,所以,在这里,我们来简单的学习一下如何在CentOS系统中进行VNC配置。

1.检查VNC客户端和服务器端是否已经安装

执行如下命令:
rpm -q vnc vnc-server
假如返回类似如下信息,
package vnc is not installed
vnc-server-4.0-8.1
则说明系统已经默认安装了vnc服务器端(一般来说,CentOS系统都默认安装了vnc server)。

2. 在CentOS系统中将用户名加入到配置文件中

使用如下命令编辑配置文件,添加帐户信息:
vi /etc/sysconfig/vncservers
做如下修改

#  # Uncomment the line below to start a VNC server on display :1  # 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  # lt;URL:http://www.uk.research.att.com/vnc/sshvnc.htmlamp;gt;.  # VNCSERVERS="1:myusername" # VNCSERVERS="1:gavin 2:john" # use the method for more user  VNCSERVERS="2:root" # VNCSERVERARGS[1]="-geometry 800x600"  VNCSERVERARGS[2]="-geometry 1024x768"  3.设置 root用户的密码

使用如下命令设置密码:vncpasswd
当提示Verify时,再次输入密码确认。

4.启动VNC服务

使用如下命令启动VNC SERVER
sbin/service vncserver start
当显示如下信息时,表示启动成功:
Starting VNC server: 2:root  [ OK ]

5.修改VNC SERVER的窗口治理器

vnc server默认使用的窗口治理器是twn,这是一个非常简单的窗口治理器,我们可以改成常用的GNOME或者KDE。
先使用如下命令进入用户的home目录:cd "/.vnc
编辑启动项:vi 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"   gnome-session #以GNOME作为VNC的窗口治理器  #startkde #kde desktop  #twm #注掉CentOS系统默认的窗口治理器

6.重启VNC SERVER

/sbin/service vncserver restart
当CentOS系统提示如下信息时,表示重启成功:
Shutting down VNC server: 2:root [ OK ]
Starting VNC server: 2:root [ OK ] 

7、从VNC view登录

在windows上安装vnc view,然后输入xxx.xxx.xxx.xxx:2,连接登录,输入密码即可。备注:假如从vnc view登录时,提示connection refused(10061),则是因为linux防火墙的问题,登录centos系统,选择SystemPreferencesRemote Desktop,勾选sharing中的两项,Security两项不勾,点击关闭,然后再重新用vnc view登录即可。

猜你喜欢

转载自brucectl.iteye.com/blog/1226795
今日推荐