1、启动vncserver
[root@localhost .vnc]# vncserver :1 (最后的:1表示端口号)
第一次启动时会要求输入登录密码。
同时可以通过[root@localhost .vnc]# vncserver -kill :1 关闭服务。
2、设置。
VNCserver设置涉及到的两个配置文件是/etc/sysconfig/vncservers和/root(视不同的用户而定)/.vnc/xstartup。
/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
#
.
# 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[2]="-geometry 800x600 -nolisten tcp
-nohttpd -localhost"
/root/.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
&(默认是twm
&,这样通过VNC登录是只能看到文字模式)
#以下两项视自己linux安装的X-window而定,我的安装的是KDE,所以用startkde
&
#gonme-session &
startkde &
设置完后注意要重新启动vnc server.
3、通过vnc客户端连接
在客户端输入(服务器ip:端口号)即可,如10.16.9.166:5901.
4、可能出现的问题:
(1)、启动/etc/init.d/vncserver
startStarting VNC server: no displays
configured [ OK ].出现这个时,要修改vncserver的配置文件vi
/etc/sysconfig/vncservers将下面这两个注释去掉即可。
#VNCSERVERS="1:root"
#VNCSERVERARGS[2]="-geometry 800x600
-nolisten tcp-nohttpd -localhost"
如果还有其他用户的话 先添加用户然后在VNCSERVERS="1:root"
添加即可如: VNCSERVERS="1:gavin 2:root 3:root"