当我尝试连接ssh
到远程计算机时,如果我不使用 ForwardX11 变量,它就会冻结-Y
。终端冻结,我无法取消操作,我必须关闭终端才能退出。
造成这种问题的主要原因可能是什么?
是否可以ssh
自动尝试另一种方法进行新的连接尝试或强制连接而不使用 ForwardX11 变量?
我的调试输出:
ssh
连接期间冻结的尝试:
$ ssh -v user@IP
OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/alper/.ssh/config
debug1: /Users/alper/.ssh/config line 9: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: /etc/ssh/ssh_config line 51: Applying options for *
debug1: Connecting to 192.168.1.8 [192.168.1.8] port 22.
debug1: Connection established.
debug1: identity file /Users/alper/.ssh/id_rsa type 0
debug1: identity file /Users/alper/.ssh/id_rsa-cert type -1
debug1: identity file /Users/alper/.ssh/id_dsa type -1
debug1: identity file /Users/alper/.ssh/id_dsa-cert type -1
debug1: identity file /Users/alper/.ssh/id_ecdsa type -1
debug1: identity file /Users/alper/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/alper/.ssh/id_ed25519 type -1
debug1: identity file /Users/alper/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/alper/.ssh/id_xmss type -1
debug1: identity file /Users/alper/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.2
debug1: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.2 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.1.8:22 as 'alper'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:ukLpqw3yNMx9D29UnmY5rSJRc6Y0ENlAK2R2DNjyljY
debug1: Host '192.168.1.8' is known and matches the ECDSA host key.
debug1: Found key in /Users/alper/.ssh/known_hosts:51
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /Users/alper/.ssh/id_rsa RSA SHA256:5HDbKAE8ePtTuGB48GSxWzeykOSUKKO5fxG2ub7YTvc
debug1: Will attempt key: /Users/alper/.ssh/id_dsa
debug1: Will attempt key: /Users/alper/.ssh/id_ecdsa
debug1: Will attempt key: /Users/alper/.ssh/id_ed25519
debug1: Will attempt key: /Users/alper/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected]>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/alper/.ssh/id_rsa RSA SHA256:5HDbKAE8ePtTuGB48GSxWzeykOSUKKO5fxG2ub7YTvc
debug1: Server accepts key: /Users/alper/.ssh/id_rsa RSA SHA256:5HDbKAE8ePtTuGB48GSxWzeykOSUKKO5fxG2ub7YTvc
debug1: Authentication succeeded (publickey).
Authenticated to 192.168.1.8 ([192.168.1.8]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: exec
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug1: Remote: /home/alper/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Remote: /home/alper/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
工作连接:
$ ssh -Yv user@IP
OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/alper/.ssh/config
debug1: /Users/alper/.ssh/config line 9: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: /etc/ssh/ssh_config line 51: Applying options for *
debug1: Connecting to 192.168.1.8 [192.168.1.8] port 22.
debug1: Connection established.
debug1: identity file /Users/alper/.ssh/id_rsa type 0
debug1: identity file /Users/alper/.ssh/id_rsa-cert type -1
debug1: identity file /Users/alper/.ssh/id_dsa type -1
debug1: identity file /Users/alper/.ssh/id_dsa-cert type -1
debug1: identity file /Users/alper/.ssh/id_ecdsa type -1
debug1: identity file /Users/alper/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/alper/.ssh/id_ed25519 type -1
debug1: identity file /Users/alper/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/alper/.ssh/id_xmss type -1
debug1: identity file /Users/alper/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.2
debug1: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.2 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.1.8:22 as 'alper'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:ukLpqw3yNMx9D29UnmY5rSJRc6Y0ENlAK2R2DNjyljY
debug1: Host '192.168.1.8' is known and matches the ECDSA host key.
debug1: Found key in /Users/alper/.ssh/known_hosts:51
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /Users/alper/.ssh/id_rsa RSA SHA256:5HDbKAE8ePtTuGB48GSxWzeykOSUKKO5fxG2ub7YTvc
debug1: Will attempt key: /Users/alper/.ssh/id_dsa
debug1: Will attempt key: /Users/alper/.ssh/id_ecdsa
debug1: Will attempt key: /Users/alper/.ssh/id_ed25519
debug1: Will attempt key: /Users/alper/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected]>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/alper/.ssh/id_rsa RSA SHA256:5HDbKAE8ePtTuGB48GSxWzeykOSUKKO5fxG2ub7YTvc
debug1: Server accepts key: /Users/alper/.ssh/id_rsa RSA SHA256:5HDbKAE8ePtTuGB48GSxWzeykOSUKKO5fxG2ub7YTvc
debug1: Authentication succeeded (publickey).
Authenticated to 192.168.1.8 ([192.168.1.8]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: exec
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug1: Remote: /home/alper/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Remote: /home/alper/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Requesting X11 forwarding with authentication spoofing.
debug1: Requesting authentication agent forwarding.
debug1: Sending environment.
debug1: Sending env LC_TERMINAL_VERSION = 3.4.20210315-nightly
debug1: Sending env LC_CTYPE = en_US.UTF-8
debug1: Sending env LC_TERMINAL = iTerm2
debug1: Sending env LC_ALL = en_US.UTF-8
debug1: Sending env LANG = en_US.UTF-8
答案1
造成这种问题的主要原因可能是什么?
最有可能的是,您的 ~/.bashrc、~/.bash_profile 或 ~/.profile 中存在某些内容,它们试图运行基于 X11 的程序。这可能是您为本地登录添加的一些代码,而没有正确检查是否设置了 $DISPLAY。
ssh 是否可以在不使用 ForwardX11 变量的情况下自动尝试另一种方法进行新的连接尝试或强制连接?
不。就 ssh 所知,连接是成功的– 服务器已接受频道请求和所有内容。只是远程端没有向您发送任何文本,但这在技术上没有任何问题,就像在漆黑一片中录制视频没有任何问题一样。