将用户名称加入到配置文件
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
# http://www.uk.research.att.com/vnc/sshvnc.html>.
# VNCSERVERS="1:myusername"
# VNCSERVERS="1:gavin 2:john" # use the method for more user
VNCSERVERS="1:gavin 2:root 3:root"
# VNCSERVERARGS[1]="-geometry 800x600"
VNCSERVERARGS[1]="-geometry 1024x768"
# 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
# http://www.uk.research.att.com/vnc/sshvnc.html>.
# VNCSERVERS="1:myusername"
# VNCSERVERS="1:gavin 2:john" # use the method for more user
VNCSERVERS="1:gavin 2:root 3:root"
# VNCSERVERARGS[1]="-geometry 800x600"
VNCSERVERARGS[1]="-geometry 1024x768"
启动vncserver服务
/sbin/service vncserver start
输入命令:
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 & #set starting GNOME desktop
#startkde & #kde desktop
#twm & #Text interface
# 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 & #set starting GNOME desktop
#startkde & #kde desktop
#twm & #Text interface
重启vncserver
/sbin/service vncserver restart