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

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

因此,我尝试使用 X11 转发从 macOS Monterey ssh 到 gentoo,但我一直收到错误:

X11 forwarding request failed on channel

我使用的命令是: ssh -X user@server

甚至-Y不起作用。

我已经在客户端安装了 XQuartz,并且也在x11-base/xorg-server服务器上安装了该包。

我也在xauth客户端和服务器上安装了。

我尝试了所有能找到的解决方案但都无济于事。

我在输出中什么也没找到,ssh -vvv -X user@server但无论如何它在这里:

debug2: client_x11_get_proto: xauth command: /opt/X11/bin/xauth -f /var/folders/mr/0y5cr1_x6q36lgg4knjg22xr0000gn/T//ssh-SLIcGx8j6IvT/xauthfile generate :0 MIT-MAGIC-COOKIE-1 untrusted timeout 1260 2>/dev/null
debug2: x11_get_proto: /opt/X11/bin/xauth -f /var/folders/mr/0y5cr1_x6q36lgg4knjg22xr0000gn/T//ssh-SLIcGx8j6IvT/xauthfile list :0 2>/dev/null
debug1: Requesting X11 forwarding with authentication spoofing.
debug2: channel 0: request x11-req confirm 1
debug3: send packet: type 98
debug1: Requesting authentication agent forwarding.
debug2: channel 0: request [email protected] confirm 0
debug3: send packet: type 98
debug2: fd 5 setting TCP_NODELAY
debug3: set_sock_tos: set socket 5 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 TMPDIR
debug3: Ignored env __CFBundleIdentifier
debug3: Ignored env XPC_FLAGS
debug3: Ignored env TERM
debug3: Ignored env DISPLAY
debug3: Ignored env SSH_AUTH_SOCK
debug3: Ignored env XPC_SERVICE_NAME
debug3: Ignored env TERM_PROGRAM
debug3: Ignored env TERM_PROGRAM_VERSION
debug3: Ignored env TERM_SESSION_ID
debug3: Ignored env SHELL
debug3: Ignored env HOME
debug3: Ignored env LOGNAME
debug3: Ignored env USER
debug3: Ignored env PATH
debug3: Ignored env SHLVL
debug3: Ignored env PWD
debug3: Ignored env OLDPWD
debug3: Ignored env EDITOR
debug1: channel 0: setting env LANG = "en_IE.UTF-8"
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env _
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

相关内容/etc/ssh/sshd_config

#AllowAgentForwarding yes
AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding no
X11DisplayOffset 10
X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
PrintLastLog no
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum non

~/.ssh/config

Host server
    ForwardAgent yes
    ForwardX11 yes
    XAuthLocation /opt/X11/bin/xauth

答案1

您需要将 XAuthLocation 放在 Mac 的 /etc/ssh/sshd_config 文件中。

另外:您确定 xauth 在 /opt/X11/bin 中吗?当我使用 MacPorts 安装它(sudo port install xauth)时,它安装在 /opt/local/bin 中。对我来说,添加以下行:

XAuthLocation /opt/local/bin/xauth

之后:

#X11Forwarding no
X11Forwarding yes

有效。

相关内容