无法在一个SSH会话中在不同终端上运行基于X的应用程序?

时间:2015-03-03 16:16:23

标签: ssh x11-forwarding

我在win8.1笔记本电脑上使用Bitvise SSH Client 6.23连接到具有Ubuntu 12.04 LTS的服务器。使用Xming并打开X11Forwarding。

对于单一终端,一切正常

Bitvise SSH客户端有一个功能,我可以用一个ssh会话打开两个终端。当我登录 term1 时,我得到:

Welcome to Ubuntu 12.04.3 LTS (GNU/Linux 3.8.0-29-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

New release '14.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

Last login: Tue Mar  3 23:38:09 2015 from 192.168.1.111
wei@wei-H8QG6:~$ env|grep -i ssh
SSH_CLIENT=192.168.1.111 64815 22
SSH_TTY=/dev/pts/3
SSH_CONNECTION=192.168.1.111 64815 192.168.1.130 22
wei@wei-H8QG6:~$ env|grep -i disp
DISPLAY=localhost:10.0
wei@wei-H8QG6:~$ xeyes
^C
wei@wei-H8QG6:~$

效果很好,然后我开了另一个终端: term2:

Last login: Wed Mar  4 00:00:41 2015 from 192.168.1.111
wei@wei-H8QG6:~$ env|grep -i ssh
SSH_CLIENT=192.168.1.111 64815 22
SSH_TTY=/dev/pts/4
SSH_CONNECTION=192.168.1.111 64815 192.168.1.130 22
wei@wei-H8QG6:~$ env|grep -i disp
DISPLAY=localhost:11.0
wei@wei-H8QG6:~$ xeyes
Incorrect authorization cookie.
^C
wei@wei-H8QG6:~$

没有眼睛出来,这是Bitvise SSH客户端的日志

23:58:47.185 Bitvise SSH Client 6.23, a fully featured SSH2 client.
Copyright (C) 2000-2015 by Bitvise Limited.
23:58:47.185 Visit www.bitvise.com for latest information about our SSH2 products.
23:58:47.185 Run 'BvSsh -help' to learn the supported command-line parameters.
23:58:47.786 Loading last used profile 'D:\User\MyDoc\wei.bscp'.
23:58:47.789 Last used profile loaded successfully.
23:58:52.401 Started a new SSH2 session.
23:58:52.409 Connecting to SSH2 server 192.168.1.130:22.
23:58:52.409 Connection established.
23:58:52.420 Server version: SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1
23:58:52.428 First key exchange started.
23:58:52.526 Received a new host key from the server. Algorithm: ECDSA/nistp256, size: 256 bits, MD5 fingerprint: ee:67:a3:77:4d:3b:5e:d4:60:51:0e:e3:ef:2c:00:5a, Bubble-Babble: xicoc-hilor-gugyc-bavar-vaget-nysys-kuvip-kosov-bykaf-dohor-suxax.
23:58:52.557 First key exchange completed using ecdh-sha2/nistp521. Session encryption: aes256-ctr, MAC: hmac-sha2-256, compression: none.
23:58:52.564 Attempting password authentication.
23:58:57.700 Authentication completed.
23:59:08.868 Enabled X11 forwarding to 127.0.0.1:6000.
23:59:08.875 Terminal channel opened.
23:59:08.875 Terminal channel: X11 forwarding accepted.
23:59:12.211 Terminal channel opened.
23:59:12.221 Terminal channel: X11 forwarding accepted.
23:59:55.778 Opened channel for X11 forwarding from 127.0.0.1:50442 to 127.0.0.1:6000.
00:00:01.138 Opened channel for X11 forwarding from 127.0.0.1:53486 to 127.0.0.1:6000.
00:00:01.146 X11 authentication failed forX11 forwarding from 127.0.0.1:53486 to 127.0.0.1:6000.
00:00:01.147 Closed channel for X11 forwarding from 127.0.0.1:53486 to 127.0.0.1:6000. Bytes sent: 40, received: 48.
00:00:08.779 Closed channel for X11 forwarding from 127.0.0.1:50442 to 127.0.0.1:6000. Bytes sent: 4308, received: 4820.

我试图关闭term1,并且X11转发在term2中仍然无效。 我也试过关闭term1和term2,并打开term3。 xeyes失败: 的 TERM3:

Last login: Wed Mar  4 00:07:56 2015 from 192.168.1.111
wei@wei-H8QG6:~$ xeyes
Incorrect authorization cookie.Incorrect authorization cookie.Incorrect authorization cookie.Incorrect authorization cookie.Error: Can't open display: localhost:10.0
wei@wei-H8QG6:~$

似乎X11Forwarding仅在SSH会话建立后打开的第一个终端上工作。之后,X11Forwarding在任何终端都不起作用。我只能重新连接SSH会话以使其再次运行。

然后我尝试创建两个SSH会话。 xeyes适用于SSH会话的第一个终端,但无法用于休息终端。

我不确定问题出在哪里,Xming X-server,Ubuntu的sshd或Bitvise SSH客户端?

1 个答案:

答案 0 :(得分:0)

我找到了一些解决方法,但没有一个感觉像是一个合适的解决方案。在修复问题之前,最后一个选项可能是最简单的。

  • 启动第二个SSH客户端(您已在问题中提及此选项)。
  • 从第一个终端导出cookie并在第二个终端导入:1。在终端1中,找到显示号码echo $DISPLAY并记下:10.0位,然后记下xauth list :10.0。 2.在第二个终端(xauth add <copy-pasted-xauth>)中添加cookie。
  • 更改终端2中的显示端口以匹配终端1的显示端口。因此,在终端1中,您将echo $DISPLAY和终端2 setenv DISPLAY <copy-pasted-display>

我不是linux大师,如果改变DISPLAY的值是可以接受的,也不知道,但它似乎可以解决问题。