2011-02-25 16:45:50| 分类: Linux Support | 标签: |举报 |字号大中小 订阅
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:http://www.uk.research.att.com/archive/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" (一定为系统用户,且牢记桌面模式编号为1)
VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost" (可自行定义分辨率,为永久定义)
注释:
一次性定义为,重启将失效:
[root@localhost: ~]#vncserver -geometry 800×600 #设置vncserver的分辨率
[root@localhost: ~]#vncserver -depth 16 #设置vncserver的色深
3设置密码
$ vncpasswd 24. 编辑配置文件
Password: Verify:
[root@localhost ~]# vi /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 & 这一步是为了能够在windows上显示linxu的桌面,否则只看到一个终端窗口
gnome-session gnome &
添加使用gnome桌面环境
vnc访问框输入
192.168.0.1:1 或者: 192.168.0.1:5901
6 关闭和启动相应编号的VNC服务命令:
vncserver -kill :x (X为编号)
关闭 vncserver -kill:1
启动 vncserver 1
错误汇总:
If you get error messages like this
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified
xhost: unable to open display ":0.0"
when running a program, you probably need to add the user to the X server access list.
You can add a user to the X server access list with
# xhost +local:username
This allows "username" to connect to the local running X server.
评论