在ssh命令中可以通过-v选项直接开启调试模式,在连接的过程中将根据设定的调试等级输出对应的信息,这篇文章以确认ssh首次连接的动作为例,说明调试模式的使用方式。
调试模式
ssh命令中,调试模式有三种,具体说明如下所示:
类别 | 设定方法 | 使用示例 | 使用说明 |
---|---|---|---|
调试模式1 | -v | ssh -v 具体命令 | 显示debug1的调试信息 |
调试模式2 | -vv | ssh -v 具体命令 | 显示debug1和debug2的调试信息 |
调试模式3 | -vvv | ssh -v 具体命令 | 显示debug1、debug2和debug3的调试信息 |
首次连接
比如在192.168.163.121这台机器上, 使用-v来确认连接的过程:
输入命令ssh -v 192.168.163.121
执行之前确认一下.ssh的密钥信息,可以看到有rsa的密钥对
[root@host121 ssh]# ls $HOME/.ssh
id_rsa id_rsa.pub
[root@host121 ssh]#
执行信息如下所示:
[root@host121 ssh]# ssh -v 192.168.163.121
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.163.121 [192.168.163.121] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
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.163.121: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:y9ir2Jbc7kNZPhP9h/O9juUZbTmGDo6NZi2IZnLwg0s
The authenticity of host '192.168.163.121 (192.168.163.121)' can't be established.
ECDSA key fingerprint is SHA256:y9ir2Jbc7kNZPhP9h