vnc无法连到linux server,但ssh可以的解决方法

今天用vnc连远程服务器,一直给我提示Failed to connect to server.
记录下解决该问题的步骤:
1 确认ssh能登录,查看vncserver是否开启。
     /etc/init.d/vncserver status
     我查看了一下我的vncserver确实处于运行状态
2 查看vncserver的设置是否正确
     打开文件/etc/sysconfig/vncservers,看到里面忘记设置属性了,于是增加两行
     VNCSERVERS="1:root"
     VNCSERVERARGS[1]="-geometry 1024x768 -alwaysshared -depth 24"
     保存后重启vncserver
3 依旧不能连接。此时检查DISPLAY变量的值,echo $DISPLAY,空值。设置DISPLAY,export DISPLAY=localhost:1,
4 查看xhost设置,命令行输入xhost +,得到输出access control disabled, clients can connect from any host。
5 再次连接,依然失败。后来想到DISPLAY设置的值后面有:1,在ip的后面加上:1,连接成功。

猜你喜欢

转载自joeyjoker.iteye.com/blog/1884091