一台机器的 SSH 连接速度很慢,而另一台机器则很快

一台机器的 SSH 连接速度很慢,而另一台机器则很快

我有一台远程服务器,需要通过 VPN 连接到另一个数据中心进行管理。我以前用来连接到该服务器的服务器(服务器 A)即将停用,因此我使用同一 VLAN 上的另一台服务器(服务器 B)。

服务器 A 和 B 运行相同版本的 SSH(SSH-2.0-OpenSSH_4.3)并具有相同的 /etc/ssh/ssh_config 文件。

服务器 A 和 B 都具有 RSA 密钥,其公共部分存储在远程机器上的 .ssh/authorized_keys 中。

当我从服务器 A ssh 到远程机器时,我立即就可以进入。

当我从服务器 B ssh 到远程机器时,我必须等待大约 20 秒或更长时间。

我已经在详细调试模式下运行 ssh,它在服务器 B 上挂起的部分如下:

debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: filename /home/user/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 1
debug1: Host '10.10.10.50' is known and matches the RSA host key.
debug1: Found key in /home/user/.ssh/known_hosts:1
debug2: bits set: 493/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/user/.ssh/identity ((nil))
debug2: key: /home/user/.ssh/id_rsa (0x7ff214705310)
debug2: key: /home/user/.ssh/id_dsa ((nil))
...

这是延迟 20 秒的点。服务器 B 发生了什么,但不会影响服务器 A?

答案1

可能是反向 DNS 查找延迟。请检查服务器 B 上的 DNS 配置。

您可以通过在 sshd_config 中设置“UseDNS no”来验证这一点,看看是否有帮助。(但是,如果存在任何潜在的 DNS 问题,最好解决它们)。

相关内容