一、问题现象
运行vncserver的时候提示出错,查看vnc的日志发现如下错误日志
litin@linuxService:~/.vnc$ cat linuxService\:4.log
Xvnc Free Edition 4.1.1 - built Jul 31 2015 19:10:31
Copyright (C) 2002-2005 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.
Underlying X server release 40300000, The XFree86 Project, Inc
Sun Feb 11 16:20:23 2018
vncext: VNC extension running!
vncext: Listening for VNC connections on port 5904
vncext: created VNC server for screen 0
error opening security policy file /etc/X11/xserver/SecurityPolicy
Could not init font path element /usr/X11R6/lib/X11/fonts/Type1/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Speedo/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/misc/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/75dpi/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/100dpi/, removing from list!
Could not init font path element /usr/share/fonts/X11/75dpi/, removing from list!
Could not init font path element /usr/share/fonts/X11/100dpi/, removing from list!
AUDIT: Sun Feb 11 16:20:26 2018: 3629 Xvnc4: client 1 rejected from local host
No protocol specified
xsetroot: unable to open display ':4'
AUDIT: Sun Feb 11 16:20:26 2018: 3629 Xvnc4: client 1 rejected from local host
No protocol specified
vncconfig: unable to open display ":4"
此版本的 gnome-terminal 已不再支持选项 "--login" ;您可能想要创建一个有期望设定的配置文件,然后使用新的“--profile”选项
AUDIT: Sun Feb 11 16:20:26 2018: 3629 Xvnc4: client 1 rejected from local host
No protocol specified
** (gnome-terminal:3636): WARNING **: Could not open X display
AUDIT: Sun Feb 11 16:20:26 2018: 3629 Xvnc4: client 1 rejected from local host
AUDIT: Sun Feb 11 16:20:26 2018: 3629 Xvnc4: client 1 rejected from local host
No protocol specified
无法处理参数:无法打开显示:
AUDIT: Sun Feb 11 16:20:26 2018: 3629 Xvnc4: client 1 rejected from local host
No protocol specified
AUDIT: Sun Feb 11 16:20:26 2018: 3629 Xvnc4: client 1 rejected from local host
AUDIT: Sun Feb 11 16:20:26 2018: 3629 Xvnc4: client 1 rejected from local host
No protocol specified
** (gnome-session:3637): WARNING **: Could not open X display
AUDIT: Sun Feb 11 16:20:26 2018: 3629 Xvnc4: client 1 rejected from local host
AUDIT: Sun Feb 11 16:20:26 2018: 3629 Xvnc4: client 1 rejected from local host
AUDIT: Sun Feb 11 16:20:26 2018: 3629 Xvnc4: client 1 rejected from local host
No protocol specified
** (gnome-session:3637): WARNING **: 无法打开显示:
AUDIT: Sun Feb 11 16:20:26 2018: 3629 Xvnc4: client 1 rejected from local host
AUDIT: Sun Feb 11 16:20:26 2018: 3629 Xvnc4: client 1 rejected from local host
二、问题分析
问题的根源是在于SecurityPolicy打开不了(“error opening security policy file /etc/X11/xserver/SecurityPolicy“),猜测这个文件的读写权限有问题。
利用命令xauth -b list可以验证
litin@linuxService:~/.vnc$ xauth -b list
xauth: /home/litin/.Xauthority not writable, changes will be ignored
三、解决方法
用chown 命令把文件”.Xauthority“改成当前用户名就可以成功启动vncserver了