解决 ssh 连接建立时间过长且没有错误的问题

解决 ssh 连接建立时间过长且没有错误的问题

我在通过 ssh 连接到特定主机(在 ubuntu 服务器 14.04 上运行)时遇到一些麻烦,该过程最多需要 9 秒才能发生。当使用调试选项 (-v) 运行 ssh 时,我得到以下输出:

    OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 19: Applying options for *
    debug1: Connecting to host_ip [host_ip] port 22.
    debug1: Connection established.
    debug1: identity file /host_home/.ssh/id_rsa type -1
    debug1: identity file /host_home/.ssh/id_rsa-cert type -1
    debug1: identity file /host_home/.ssh/id_dsa type -1
    debug1: identity file /host_home/.ssh/id_dsa-cert type -1
    debug1: identity file /host_home/.ssh/id_ecdsa type -1
    debug1: identity file /host_home/.ssh/id_ecdsa-cert type -1
    debug1: identity file /host_home/.ssh/id_ed25519 type -1
    debug1: identity file /host_home/.ssh/id_ed25519-cert type -1
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.11
    debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.11
    debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.11 pat OpenSSH_6.6.1* compat 0x04000000
    debug1: SSH2_MSG_KEXINIT sent
    debug1: SSH2_MSG_KEXINIT received
    debug1: kex: server->client aes128-ctr [email protected] none
    debug1: kex: client->server aes128-ctr [email protected] none
    debug1: sending SSH2_MSG_KEX_ECDH_INIT
    debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
    debug1: Server host key: ECDSA 2a:cb:66:69:ce:14:94:83:59:d5:4b:ea:87:15:be:23
    debug1: Host 'host_ip' is known and matches the ECDSA host key.
    debug1: Found key in /host_home/.ssh/known_hosts:4
    debug1: ssh_ecdsa_verify: signature correct
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug1: SSH2_MSG_NEWKEYS received
    debug1: SSH2_MSG_SERVICE_REQUEST sent
    debug1: SSH2_MSG_SERVICE_ACCEPT received
**_____the abnormal delay starts here_____**
    debug1: Authentications that can continue: publickey,password
    debug1: Next authentication method: publickey
    debug1: Trying private key: /host_home/.ssh/id_rsa
    debug1: Trying private key: /host_home/.ssh/id_dsa
    debug1: Trying private key: /host_home/.ssh/id_ecdsa
    debug1: Trying private key: /host_home/.ssh/id_ed25519
    debug1: Next authentication method: password

没有检测到特定的错误或异常,但我注意到身份验证步骤花费的时间太长。

我不知道是否有一些硬件规格可能与此有关。或者也许是更高级的调试模式。

答案1

问题解决了!

就我而言,这基本上是一个问题网络配置我的主人有域名系统但在其中工作当地的网络。删除文件dns-nameservers中的后network/interfaces,一切恢复正常。

如果有人能够详细解释 dns 验证过程以及为什么在调试模式下运行时没有报告问题,我会很高兴。

相关内容