ssh -X 警告:X11 转发请求在通道 0 上失败

ssh -X 警告:X11 转发请求在通道 0 上失败

当我运行时,ssh -X my_host我收到错误:“X11 转发请求在通道 0 上失败”。 (ssh -Y my_host给出相同的错误)

我的主机是 Gentoo Linux 机器,我的客户端是 macOS Catalina。主机和客户端都已xauth安装。客户端安装了 XQuartz-2.7.11。

我已将这些行ForwardX11 yes和添加X11UseLocalhost no到主机上的 /etc/ssh/ssh_config 文件中,但这没有帮助。

有什么办法可以解决这个问题吗?

可能相关信息:

  1. xauth list $DISPLAY在主机和客户端上均未提供任何输出。
  2. 我在客户端的“.ssh/config”文件中添加了XAuthLocation /opt/X11/bin/xauthForwardX11Trusted yes和。ForwardX11 yes

编辑:最后几行ssh -vvvX my_host是:

Authenticated to ******.
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting [email protected]
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: exec
debug3: receive packet: type 80
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug3: receive packet: type 4
debug1: Remote: /home/user/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug3: receive packet: type 4
debug1: Remote: /home/user/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug3: receive packet: type 91
debug2: channel_input_open_confirmation: channel 0: callback start
debug2: x11_get_proto: /opt/X11/bin/xauth  list /private/tmp/com.apple.launchd.MRsK0ea50W/org.macosforge.xquartz:0 2>/dev/null
debug1: Requesting X11 forwarding with authentication spoofing.
debug2: channel 0: request x11-req confirm 1
debug3: send packet: type 98
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x48
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug3: send packet: type 98
debug1: Sending environment.
debug3: Ignored env CONDA_DEFAULT_ENV
debug3: Ignored env CONDA_EXE
debug3: Ignored env CONDA_PREFIX
debug3: Ignored env CONDA_PROMPT_MODIFIER
debug3: Ignored env CONDA_PYTHON_EXE
debug3: Ignored env CONDA_SHLVL
debug3: Ignored env DISPLAY
debug3: Ignored env HOME
debug3: Ignored env JAVA_HOME
debug1: Sending env LC_CTYPE = UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env LOGNAME
debug3: Ignored env LaunchInstanceID
debug3: Ignored env PATH
debug3: Ignored env PWD
debug3: Ignored env SECURITYSESSIONID
debug3: Ignored env SHELL
debug3: Ignored env SHLVL
debug3: Ignored env SSH_AUTH_SOCK
debug3: Ignored env TERM
debug3: Ignored env TERM_PROGRAM
debug3: Ignored env TERM_PROGRAM_VERSION
debug3: Ignored env TERM_SESSION_ID
debug3: Ignored env TMPDIR
debug3: Ignored env USER
debug3: Ignored env XPC_FLAGS
debug3: Ignored env XPC_SERVICE_NAME
debug3: Ignored env _CE_CONDA
debug3: Ignored env _CE_M
debug3: Ignored env __CF_USER_TEXT_ENCODING
debug2: channel 0: request shell confirm 1
debug3: send packet: type 98
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug3: receive packet: type 100
debug2: channel_input_status_confirm: type 100 id 0
X11 forwarding request failed on channel 0
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0

主机日志:

Aug 31 15:44:52 Jimmy sshd[12245]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=****  user=root
Aug 31 15:44:52 Jimmy sshd[12245]: pam_faillock(sshd:auth): Error opening the tally file for root: No such file or directory
Aug 31 15:44:53 Jimmy sshd[12026]: error: PAM: Authentication failure for root from ****
Aug 31 15:44:54 Jimmy sshd[12247]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=****  user=root
Aug 31 15:44:54 Jimmy sshd[12247]: pam_faillock(sshd:auth): Error opening the tally file for root: No such file or directory
Aug 31 15:44:56 Jimmy sshd[12026]: error: PAM: Authentication failure for root from ****
Aug 31 15:44:56 Jimmy sshd[12248]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=****  user=root
Aug 31 15:44:56 Jimmy sshd[12248]: pam_faillock(sshd:auth): Error opening the tally file for root: No such file or directory
Aug 31 15:44:58 Jimmy sshd[12026]: error: PAM: Authentication failure for root from ****
Aug 31 15:44:58 Jimmy sshd[12026]: Received disconnect from **** port 19854:11:  [preauth]
Aug 31 15:44:58 Jimmy sshd[12026]: Disconnected from authenticating user root **** port 19854 [preauth]
Aug 31 15:45:07 Jimmy sshd[11912]: Received disconnect from 81.28.198.29 port 50547:11: disconnected by user
Aug 31 15:45:07 Jimmy sshd[11912]: Disconnected from user my_user 81.28.198.29 port 50547
Aug 31 15:45:07 Jimmy sshd[11910]: pam_unix(sshd:session): session closed for user my_user
Aug 31 15:45:07 Jimmy kernel: elogind-daemon[20296]: Removed session c56.
Aug 31 15:45:13 Jimmy sshd[12253]: Accepted publickey for my_user from **** port 50605 ssh2: RSA SHA256:****
Aug 31 15:45:13 Jimmy kernel: elogind-daemon[20296]: Existing logind session ID 1 used by new audit session, ignoring.
Aug 31 15:45:13 Jimmy kernel: elogind-daemon[20296]: New session c57 of user my_user.
Aug 31 15:45:13 Jimmy sshd[12253]: pam_unix(sshd:session): session opened for user my_user(uid=1000) by (uid=0)

答案1

在远程服务器上,必须在 ssh 中将“X11Forwarding”设置为“yes”d配置(/etc/ssh/sshd_config)。如果你使用 ssh -X,则无需在客户端上更改 ssh 客户端配置(/etc/ssh/ssh_config)

ssh 命令中的参数将覆盖您本地机器上的 ssh 客户端配置(/etc/ssh/ssh_config)的默认值。请注意 ssh_config 与 sshd_config - 以及 - 客户端与服务器。sshd 也可以安装在您的本地机器上,但客户端和服务器仅意味着:一方启动概念而另一方接受连接(列出时)。

通过 ssh 成功登录后,DISPLAY应将变量设置为类似的值,localhost:10.0否则 X11 转发将不起作用。

提示:如果您正在连接到本地服务器(在 LAN 上),则可以跳过 ssh X11 隧道,只需在服务器上执行 export DISPLAY=<clientIP>:0 并在客户端上发出“xhost +<serverIPorFQDN>”。这比通过 SSH 隧道传输 X 快得多。

相关内容