#通过命令:ssh -v root@192.168.137.10 可得到如下输出
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to 192.168.137.10 [192.168.137.10] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: SELinux support enabled
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.137.10:22 as 'root'
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: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: curve25519-sha256 need=64 dh_need=64
debug1: kex: curve25519-sha256 need=64 dh_need=64
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:d+sZJgkaFFcs6z/Phsa1Bk/fna+L9BwPMlKqfVq1/14
The authenticity of host '192.168.137.10 (192.168.137.10)' can't be established.
ECDSA key fingerprint is SHA256:d+sZJgkaFFcs6z/Phsa1Bk/fna+L9BwPMlKqfVq1/14.
ECDSA key fingerprint is MD5:6e:8a:08:c7:92:72:ff:3b:c6:30:cb:7a:08:59:6e:b4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.137.10' (ECDSA) to the list of known hosts.
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
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,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: Next authentication method: password
root@192.168.137.10's password:
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
root@192.168.137.10's password:
debug1: Authentication succeeded (password).
Authenticated to 192.168.137.10 ([192.168.137.10]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: Sending environment.
debug1: Sending env LANG = zh_CN.UTF-8
Last failed login: Fri Aug 13 00:25:06 CST 2021 from 192.168.137.10 on ssh:notty
There was 1 failed login attempt since the last successful login.
Last login: Fri Aug 13 00:17:51 2021 from gateway
ssh -v 显示过程中的debug信息,可以很清楚观测到是那个地方卡住了
3. 解决办法
#修改ssh配置文件GSSAPIAuthentication参数
[root@localhost ~]# grep -n GSSAPIAuthentication /etc/ssh/ssh_config
27:# GSSAPIAuthentication no
59: GSSAPIAuthentication no
#修改sshd配置文件usedns的参数
[root@localhost ~]# grep -ni dns /etc/ssh/sshd_config
115:UseDNS no
[root@localhost ~]#
#重启sshd服务
[root@localhost ~]# systemctl restart sshd
4. ssh免密登录本机
#将id_rsa.pub文件内容写入至authorized_keys
[root@localhost .ssh]# cat id_rsa.pub >> authorized_keys
[root@localhost ~]# hostname -I
192.168.137.10
[root@localhost ~]# ssh root@192.168.137.10
Last login: Fri Aug 13 01:02:00 2021 from 192.168.137.10
[root@localhost ~]# hostname -I
192.168.137.10