欢迎光临
我们一直在努力

在SSH中启用调试模式来解决连接问题

在本文中,我们将向您展示如何在Linux中运行SSH时打开调试模式。 这将使您能够看到执行ssh命令以使用详细模式或调试模式连接到远程Linux服务器时实际展开的内容。

另请参阅在Linux中加速SSH连接的4种方法

ssh客户端的-v开关允许您以详细模式运行ssh,打印有关SSH连接进度的调试信息,这对于调试连接,验证和任何配置问题非常有用。 有不同程度的冗长; 使用多个-v标志会增加冗长度(最大冗余级别为3)。

以下命令将在第一级别冗长的情况下运行SSH,这将给我们提供大量的调试信息,如图所示。

[email protected] ~ $ ssh -v [email protected]
示例输出
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g-fips  1 Mar 2016debug1: Reading configuration data /home/aaronkilik/.ssh/configdebug1: /home/aaronkilik/.ssh/config line 18: Applying options for *debug1: Reading configuration data /etc/ssh/ssh_configdebug1: /etc/ssh/ssh_config line 19: Applying options for *debug1: Connecting to 192.168.56.10 [192.168.56.10] port 22.debug1: Connection established.debug1: identity file /home/aaronkilik/.ssh/id_rsa type 1debug1: key_load_public: No such file or directorydebug1: identity file /home/aaronkilik/.ssh/id_rsa-cert type -1debug1: key_load_public: No such file or directorydebug1: identity file /home/aaronkilik/.ssh/id_dsa type -1debug1: key_load_public: No such file or directorydebug1: identity file /home/aaronkilik/.ssh/id_dsa-cert type -1debug1: key_load_public: No such file or directorydebug1: identity file /home/aaronkilik/.ssh/id_ecdsa type -1debug1: key_load_public: No such file or directorydebug1: identity file /home/aaronkilik/.ssh/id_ecdsa-cert type -1debug1: key_load_public: No such file or directorydebug1: identity file /home/aaronkilik/.ssh/id_ed25519 type -1debug1: key_load_public: No such file or directorydebug1: identity file /home/aaronkilik/.ssh/id_ed25519-cert type -1debug1: Enabling compatibility mode for protocol 2.0debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000debug1: Authenticating to 192.168.56.10:22 as 'howtoing'debug1: SSH2_MSG_KEXINIT sentdebug1: SSH2_MSG_KEXINIT receiveddebug1: kex: algorithm: [email protected]debug1: kex: host key algorithm: ecdsa-sha2-nistp256debug1: kex: server->client cipher: [email protected] MAC:  compression: [email protected]debug1: kex: client->server cipher: [email protected] MAC:  compression: [email protected]debug1: expecting SSH2_MSG_KEX_ECDH_REPLYdebug1: Server host key: ecdsa-sha2-nistp256 SHA256:1778erqyug4tHJa7D6y/Ep4UWsUtNEOBSMaj32k9oO8debug1: Host '192.168.56.10' is known and matches the ECDSA host key.debug1: Found key in /home/aaronkilik/.ssh/known_hosts:8debug1: rekey after 134217728 blocksdebug1: SSH2_MSG_NEWKEYS sentdebug1: expecting SSH2_MSG_NEWKEYSdebug1: rekey after 134217728 blocksdebug1: SSH2_MSG_NEWKEYS receiveddebug1: SSH2_MSG_EXT_INFO receiveddebug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>debug1: SSH2_MSG_SERVICE_ACCEPT receiveddebug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,passworddebug1: Next authentication method: publickeydebug1: Offering RSA public key: /home/aaronkilik/.ssh/id_rsadebug1: Server accepts key: pkalg rsa-sha2-512 blen 279debug1: Enabling compression at level 6.debug1: Authentication succeeded (publickey).Authenticated to 192.168.56.10 ([192.168.56.10]:22).debug1: channel 0: new [client-session]debug1: Requesting [email protected]debug1: Entering interactive session.debug1: pledge: networkdebug1: client_input_global_request: rtype [email protected] want_reply 0debug1: Sending environment.debug1: Sending env LC_PAPER = lg_UG.UTF-8debug1: Sending env LC_ADDRESS = lg_UG.UTF-8debug1: Sending env LC_MONETARY = lg_UG.UTF-8debug1: Sending env LC_NUMERIC = lg_UG.UTF-8debug1: Sending env LC_TELEPHONE = lg_UG.UTF-8debug1: Sending env LC_IDENTIFICATION = lg_UG.UTF-8debug1: Sending env LANG = en_US.UTF-8debug1: Sending env LC_MEASUREMENT = lg_UG.UTF-8debug1: Sending env LC_NAME = lg_UG.UTF-8Last login: Sat Jan  6 16:20:11 2018 from 192.168.56.1

尝试注销或退出会话时,您还将看到如图所示的调试消息。

[[email protected] ~]$ exitlogoutdebug1: client_input_channel_req: channel 0 rtype exit-status reply 0debug1: client_input_channel_req: channel 0 rtype [email protected] reply 0debug1: channel 0: free: client-session, nchannels 1Connection to 192.168.56.10 closed.Transferred: sent 3392, received 3120 bytes, in 118.1 secondsBytes per second: sent 28.7, received 26.4debug1: Exit status 0debug1: compress outgoing: raw data 1159, compressed 573, factor 0.49debug1: compress incoming: raw data 573, compressed 1159, factor 2.02

接下来,您可以为更多的调试消息启用额外的(2级和3级)详细信息,如图所示。

$ ssh -vv [email protected]$ ssh -vvv [email protected]

而已! 有关SSH的更多用法,请阅读以下相关文章。

  1. 如何在Linux中查找所有失败的SSH登录尝试
  2. 如何在Linux中禁用SSH root登录
  3. 在5个简单步骤中使用SSH Keygen进行SSH无密码登录
  4. 如何在Linux中断开非活动或闲置的SSH连接

我们希望您觉得这篇文章有用。 您可以通过下面的评论表格询问任何问题或分享想法。

赞(0) 打赏
未经允许不得转载:老赵部落 » 在SSH中启用调试模式来解决连接问题
data-ad-format="auto" data-full-width-responsive="true">

评论 抢沙发