分类: LINUX
2010-07-04 22:19:48
Redhat下vnc
server多用户连接失败
一:问题
1.1安装vncserver
yum install vncserver
1.2 修改/etc/sysconfig/vncservers
取消以下两行的注释
VNCSERVERARGS[2]="-geometry 800x600
-nolisten tcp -nohttpd -localhost"
1.3设置访问密码及修改配置文件
执行
修改$HOME/.vnc/xstartup,取消以下两行的注释
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
1.4 启动vncserver
/etc/init.d/vncserver restart
启动成功后,发现只有ip:1 能登录 而ip:2登录不了。
二:分析
通过ps查看进程发现启动vnc display的参数不一样
[root@localhost
~]# ps -ef | grep vnc
root 8041
1 0 04:56 pts/4 00:00:01 Xvnc :1 -desktop
localhost.localdomain:1 (root) -httpd /usr/share/vnc/classes -auth
/root/.Xau thority
-geometry 1024x768 -depth 16 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport
5901 -pn
oracle 8575
1 1 05:05 ? 00:00:00 Xvnc :2 -desktop
localhost.localdomain:2 (oracle) -httpd /usr/share/vnc/classes -auth
/home/or acle/.Xauthority
-geometry 1024x768 -depth 16 -rfbwait 30000 -rfbauth /home/oracle/.vnc/passwd
-rfbport 5902 –pn
查看/etc/init.d/vncserver 发现开启vncserver的语句是40行:
runuser
-l ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] &&
vncserver :${DISP} ${VNCUSERARGS}"
而${VNCUSERARGS}是启动的时候带的参数,问题应该就出在这。
三:解决办法
解决的方法有一下两种:
1 修改/etc/init.d/vncserver 找到40行修改为
runuser
-l ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] &&
vncserver :${DISP}"
2、修改/etc/sysconfig/vncserver 注释掉下面这行
VNCSERVERARGS[2]="-geometry
800x600 -nolisten tcp -nohttpd -localhost"
现在重启/etc/init.d/vncserver restart
现在执行ps 发现参数一直,也能使用另外的用户访问了。
[root@localhost
~]# ps -ef |grep vnc
root 10389
1 1 05:47 pts/1 00:00:02 Xvnc :1 -desktop
localhost.localdomain:1 (root) -httpd /usr/share/vnc/classes -auth
/root/.Xauthority -geometry 1024x768 -depth 16 -rfbwait 30000 -rfbauth
/root/.vnc/passwd -rfbport 5901 -pn
oracle 10492
1 0 05:47 ? 00:00:01 Xvnc :2 -desktop
localhost.localdomain:2 (oracle) -httpd /usr/share/vnc/classes -auth
/home/oracle/.Xauthority -geometry 1024x768 -depth 16 -rfbwait 30000 -rfbauth
/home/oracle/.vnc/passwd -rfbport 5902 –pn
四:补遗
Vncserver的配置文件只设置了display2的参数
# 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.
也可以去掉-localhost参数,或者设置vncview