使用 X11 时出现错误“Gtk-WARNING **: 无法打开显示:”

使用 X11 时出现错误“Gtk-WARNING **: 无法打开显示:”
  1. 环境是这样的:
    本地主机是Ubuntu 18.04,远程主机是Debian 9。远程主机上有一些虚拟机。
  2. 我发现:
    今天我想管理远程主机上的虚拟机, ssh -x照常使用。但这次我登录时,它显示xhost: unable to open display ""。当我执行时virt-manager,它显示如下:
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused

(virt-manager:16045): Gtk-WARNING **: cannot open display: 
  1. 我尝试解决这个问题:首先我检查了我的本地主机/etc/ssh/ssh_config并确保它已按如下所示配置:
ForwardAgent yes
ForwardX11 yes
ForwardX11Trusted yes

然后检查远程主机/etc/ssh/ssh_config并确保其配置如下:

 X11Forwarding yes
 X11DisplayOffset 10
 PrintMotd no
 PrintLastLog yes
 TCPKeepAlive yes

然后我执行virt-manager,仍然显示如下:

Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused

(virt-manager:16045): Gtk-WARNING **: cannot open display: 

然后我尝试了下面几个命令,但似乎没用。

$ sudo vncserver

New 'My_Local_Host:15 (root)' desktop at :15 on machine My_Local_Host

Starting applications specified in /etc/X11/Xvnc-session
Log file is /root/.vnc/My_Local_Host:15.log

Use xtigervncviewer -SecurityTypes VncAuth -passwd /root/.vnc/passwd :15 to connect to the VNC server.
$ export DISPLAY=localhost:15
$ xhost +
xhost:  unable to open display "localhost:15"

最后我安装gksu并尝试用它打开virt-manager,但仍然无用:

gksu virt-manager 

(gksu:17242): Gtk-WARNING **: cannot open display: localhost:15

你能给我一些建议吗?谢谢!

相关内容