本机 SSH 客户端无法再连接,但 scp 和 PyCharm SSH 客户端可以正常工作吗?

本机 SSH 客户端无法再连接,但 scp 和 PyCharm SSH 客户端可以正常工作吗?

我今天遇到了一个非常奇怪的问题,我不记得做了任何更改。当我尝试连接到客户端时,我的 SSH 客户端挂起了(参见下面的输出片段)。但是,scp 可以很好地连接到同一个地址,PyCharm 也可以正常工作(它有自己的 SSH 客户端),并且我网络上的其他人可以通过 SSH 进入。我也无法通过 SSH 进入任何其他客户端。

user@user:~$ ssh [email protected] -v
OpenSSH_7.2p2 Ubuntu-4, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /home/user/.ssh/config
debug1: /home/user/.ssh/config line 2: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 192.168.1.1 [192.168.1.1] port 22.

使用 Ubuntu 16.04.2、openssh-client,没有防火墙或类似的东西。

* 添加 scp 调试输出

user@user:~$ scp -v [email protected]:FILE .
Executing: program /usr/bin/ssh host 192.168.1.1, user user, command scp -v -f FILE
OpenSSH_7.2p2 Ubuntu-4, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 192.168.1.1 [192.168.1.1] port 22.
debug1: Connection established.
debug1: SELinux support disabled
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.1
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.1.1:22 as 'user'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: [email protected]
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:zxclXzh+D5j1+BwcOUly8AChlfh9Hqdoh651rShR7Bo
The authenticity of host '192.168.1.1 (192.168.1.1)' can't be established.
ECDSA key fingerprint is SHA256:zxclXzh+D5j1+BwcOUly8AChlfh9Hqdoh651rShR7Bo.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.1' (ECDSA) to the list of known hosts.
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /home/user/.ssh/id_rsa
debug1: Trying private key: /home/user/.ssh/id_dsa
debug1: Trying private key: /home/user/.ssh/id_ecdsa
debug1: Trying private key: /home/user/.ssh/id_ed25519
debug1: Next authentication method: password
[email protected]'s password: 
debug1: Authentication succeeded (password).
Authenticated to 192.168.1.1 ([192.168.1.1]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug1: Sending environment.
debug1: Sending env LANG = en_CA.UTF-8
debug1: Sending command: scp -v -f FILE
Sending file modes: C0664 329835 FILE
Sink: C0664 329835 FILE
FILE                                                                        100%  322KB 322.1KB/s   00:00    
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype [email protected] reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 1988, received 332744 bytes, in 0.2 seconds
Bytes per second: sent 10317.9, received 1726971.4
debug1: Exit status 0

答案1

我会检查我的/home/user/.ssh/config

SSH 客户端读取它,而 SCP 则不会。

此外,您的调试日志显示:

debug1:/home/user/.ssh/config 第 2 行:应用选项 *

...所以您的用户配置中的一些内容(至少两行)。

我不知道可以通过该文件执行的任何恶作剧1可以阻止连接并出现您观察到的症状,但您永远不知道......


(1)例如设置IdentityFile/dev/zero,在SendEnv中放置有趣的值,使用UTF-8“不可见”字符......

相关内容