随笔-167  评论-8  文章-0  trackbacks-0

其实其它linux平台也差不多。

VNC client software (tightVNC, you can download it here.)

RHEL下默认有了Xvnc,只是服务没有启动,免安装。

下面启动vnc服务:

# service vncserver startStarting VNC server:                     [  OK  ]# vncpasswdPassword: Verify: # vncserverNew 'roswell:1 (root)' desktop is roswell:1Starting applications specified in /root/.vnc/xstartupLog file is /root/.vnc/roswell:1.log此时可以通过vnc客户端软件(端口默认5901)或浏览器(端口默认5801,如 http://192.168.0.1:5801 )登陆,输入刚才设置的密码。此时默认不是gnome或kde界面,如果不想使用默认的twm,还有修改用户主目录下.vnc目录里的xstartup(注意这个文件是在vnc client登陆后自动生成的):# 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" &
startx &

然后再重启vncserver即可,目前都是以root身份登陆的,太危险了。
需要设置具体登陆的用户和分辨率,可以修改/etc/sysconfig/vncservers文件:

# vi /etc/sysconfig/vncservers
# The VNCSERVERS variable is a list of display:user pairs.
#
# 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
# <URL:http://www.uk.research.att.com/vnc/sshvnc.html>.

VNCSERVERS="1:oracle"
VNCSERVERARGS[1]="-geometry 1024x768"

/etc/sysconfig/vncserver要这样设置:

为每个你允许使用vnc的用户添加两行
VNCSERVERS="x:username"
VNCSERVERARGS[x]="-geometry 800x600 -query localhost"

这里,第一行中x>0,5800+x和5900+x分别是vnc监听的端口,前者是使用http协议的,第二行是设置该用户vnc进程的参数。

例如:
VNCSERVERS="3:foo"
VNCSERVERARGS[3]="-geometry 800x600 -query localhost"

表示用户foo可以通过 http://serverip:5803/ 或用vnc viewer连接serverip:5903 来访问。

最后,要为每个使用vnc的用户用vncpasswd命令设置访问口令。

重启vncserver:

# service vncserver status
Xvnc (pid 5718) is running...
# service vncserver restart
Shutting down VNC server:                                  [ OK ]
Starting VNC server:                                       [ OK ]
# service vncserver status
Xvnc (pid 5718) is running...
# kill 5718
# kill 5718
-bash: kill: (5718) - No such process
# service vncserver start
Starting VNC server: 1:oracle                              [ OK ]
# service vncserver status
Xvnc (pid 7679) is running...
#

posted on 2009-12-22 18:16 老马驿站 阅读(532) 评论(0)  编辑 收藏 引用 所属分类: linux