1) 配置允许访问的用户
[root@RHCE ~]# vi /etc/sysconfig/vncservers
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# 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:[url]http://www.uk.research.att.com/archive/vnc/sshvnc.html[/url]>.
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
# Use "-nohttpd" to prevent web-based VNC clients connecting.
# Use "-localhost" to prevent remote VNC clients connecting except when
# doing so through a secure tunnel.  See the "-via" option in the
# `man vncviewer' manual page.
# VNCSERVERS="2:myusername"
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"
# 自己定义部分:运行用户jchen远程访问,分辨率为800*600
VNCSERVERS="2:jchen"
VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd"
# 自己定义部分:运行用户jackie远程访问,分辨率为1024*768
VNCSERVERS="3:jackie"
VNCSERVERARGS[3]="-geometry 1024x768"
2) 配置用户VNC访问密码
[root@RHCE ~]# su - jackie
[jackie@RHCE ~]$ mkdir .vnc
[jackie@RHCE ~]$ cd .vnc
[jackie@RHCE .vnc]$ vncpasswd
Password: xxxxxx
Verify: xxxxxx
3) 启动VNC服务
[root@RHCE ~]# service vncserver start
4) 配置VNC访问方式
[root@RHCE ~]# vi /home/jackie/.vnc/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" &
twm &
5) 配置iptables允许访问5902端口
[root@RHCE ~]# iptables -I RH-Firewall-1-INPUT -p tcp --dport 5903 -j ACCEPT
[root@RHCE ~]# iptables -I RH-Firewall-1-INPUT -p udp --dport 5903 -j ACCEPT
6) Windows下测试成功
image
image