[iyunv@localhost ~]# vi ~/.vnc/xstartup #编辑这个配置脚本文件,配置使远程登录为gnome或者kde桌面。
1
2
3
4
5
6
7
8
9
10
11
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
[ -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 &
gnome-session &
#startkde & 若是用kde桌面,则将开始#号去掉,注释上面的gnome
如果还要为其它的用户名配置vnc,方法同上,只需要改一下端口号就行
2.接下来编辑vnc的配置文件
1
[iyunv@localhost~]#vi /etc/sysconfig/vncservers
以下是文件内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# The VNCSERVERS variable is a list of display:user pairs.
# 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>.
# 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= “ 1:root “
VNCSERVERARGS [ 1 ] = “ -geometry 1024×768 “
解释一下这个文件:
VNCSERVERS这一行是配置在系统启动时启动几个VNC server,上面的例子里运行了一个VNC server,root在display:1 VNCSERVERARGS这行,为VNC server 1配置启动参数,上面的例子里对root使用屏幕分辨率1024×768。
设置完成后就可以启动vncserver服务了。
防止VNC已经启动,我们用重新启动的命令以防万一