使用 ssh -X 时 X11 连接使用不同的身份验证协议

jol*_*ier 6 ssh xorg xauth

我无法在其中一台服务器上使用 X 应用程序。(同一个客户端成功连接到其他服务器,所以问题不在客户端)。

我连接ssh -vvv -Y -4 jet(也尝试使用-X而不是-Y,同样的问题)强制使用 IPv4(这已经解决了以前的错误)。但是当我启动一个需要 XI 的应用程序时,得到以下信息:

debug1: client_input_channel_open: ctype x11 rchan 3 win 65536 max 16384
debug1: client_request_x11: request from 127.0.0.1 42026
debug2: fd 7 setting O_NONBLOCK
debug3: fd 7 is O_NONBLOCK
debug1: channel 1: new [x11]
debug1: confirm x11
debug2: X11 connection uses different authentication protocol.
X11 connection rejected because of wrong authentication.
debug2: X11 rejected 1 i0/o0
debug2: channel 1: read failed
debug2: channel 1: close_read
debug2: channel 1: input open -> drain
debug2: channel 1: ibuf empty
debug2: channel 1: send eof
debug2: channel 1: input drain -> closed
debug2: channel 1: write failed
debug2: channel 1: close_write
debug2: channel 1: output open -> closed
debug2: X11 closed 1 i3/o3
debug2: channel 1: send close
debug2: channel 1: rcvd close
debug2: channel 1: is dead
debug2: channel 1: garbage collecting
debug1: channel 1: free: x11, nchannels 2
debug3: channel 1: status: The following connections are open:
  #0 client-session (t4 r0 i0/0 o0/0 fd 4/5 cc -1)
  #1 x11 (t7 r3 i3/0 o3/0 fd 7/7 cc -1)

xterm Xt error: Can't open display: JET:10.0
Run Code Online (Sandbox Code Playgroud)

xauth list 给我

JET:11  MIT-MAGIC-COOKIE-1  8d5c49524a122751ec382da3613c9408
JET:10  MIT-MAGIC-COOKIE-1  6582c5c546ca979132e2d32c64ef481d
Run Code Online (Sandbox Code Playgroud)

echo $DISPLAY 给我

JET:10.0
Run Code Online (Sandbox Code Playgroud)

所以我有这个显示器的cookies。

我在服务器上的 SSH 版本是:

OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010
Run Code Online (Sandbox Code Playgroud)

从网上找到的各种解决方案中,有类似的东西

xauth generate $DISPLAY MIT-MAGIC-COOKIE-1
Run Code Online (Sandbox Code Playgroud)

但是当我运行这个命令时,我得到了与运行 X 程序时相同的错误(即使我rm ~/.Xauthority之前)。

我在 ssh 之后没有 sudoed,我通过私钥进行身份验证。我的服务器在 CentOs 上,我有以下 ssh 服务器配置sudo cat /etc/ssh/sshd_config|egrep -v "^#"

ListenAddress 0.0.0.0
Protocol 2
SyslogFacility AUTHPRIV
LogLevel DEBUG3
PasswordAuthentication yes
ChallengeResponseAuthentication no
GSSAPIAuthentication yes
GSSAPICleanupCredentials yes
UsePAM yes
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no
Subsystem   sftp    /usr/libexec/openssh/sftp-server
Run Code Online (Sandbox Code Playgroud)

关于什么可能导致这种情况的任何提示?

Hei*_*ann 5

以下为我解决了这个问题,参见。ssh-x11-not-working by azat

ssh X 转发不起作用的原因是我有一个 /etc/ssh/sshrc配置文件。

sshd(8)手册页的末尾指出:

 如果 ~/.ssh/rc 存在,
运行它;否则如果 /etc/ssh/sshrc 存在,运行它;否则运行 xauth

因此,我将以下命令添加到/etc/ssh/sshrc服务器端(也来自 sshd 手册页):

    # example sshrc file
    if read proto cookie && [ -n "$DISPLAY" ]; then
             if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
                     # X11UseLocalhost=yes
                     echo add unix:`echo $DISPLAY |
                         cut -c11-` $proto $cookie
             else
                     # X11UseLocalhost=no
                     echo add $DISPLAY $proto $cookie
             fi | xauth -q -
    fi
Run Code Online (Sandbox Code Playgroud)

它有效!

注意:编辑以使示例 sshrc 中的两组反引号更清晰。复制时要小心!


Ant*_*nti 2

我只是在这里尝试一下,但由于您遇到了 xauth 问题,也许这与受信任的 X11 转发有关。您是否尝试过通过 ssh 连接执行相同的步骤ssh -vvv -X -4 jet