我注意到网络中的某些 Linux 服务器需要很长时间才能使用 ssh 进行连接。
情况:
我遇到过两种情况:
在某些服务器上有时需要很长时间才能要求密码
但在其他服务器上,当我插入密码时,它没有响应。一段时间后说 20 0r 30 秒它只是说连接关闭
1个案例的详细信息:
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
Cannot determine realm for numeric host address
debug1: Unspecified GSS failure. Minor code may provide more information
Cannot determine realm for numeric host address
debug1: Unspecified GSS failure. Minor code may provide more information
debug1: Unspecified GSS failure. Minor code may provide more information
Cannot determine realm for numeric host address
debug2: we did not send a packet, disable method
debug1: Next authentication method: publickey
debug1: Trying private key: /home/umairmustafa/.ssh/id_rsa
debug1: Trying private key: /home/umairmustafa/.ssh/id_dsa
debug1: Trying private key: /home/umairmustafa/.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug1: Next authentication method: password
Run Code Online (Sandbox Code Playgroud)
Mik*_*keV 52
我今天早上也遇到了同样的问题...
编辑您/etc/ssh/sshd_config
的设置GSSAPIAuthentication no
rep*_*lay 28
当 DNS 配置不正确时,我经常会遇到这种情况,但 SSH 试图对每次连接进行反向查找,因此它可能正在等待一些高超时。尝试这样做/etc/ssh/sshd_config
:
UseDNS no
Run Code Online (Sandbox Code Playgroud)
然后重新启动 SSH 守护进程。这将使它不再使用反向查找。
小智 7
如果您不想更改任何服务器配置
前往$HOME/.ssh/config
并添加
Host *
GSSAPIAuthentication no
Run Code Online (Sandbox Code Playgroud)
小智 5
我发现了另一个导致 ssh 需要一两分钟才能连接的原因。如果您按如下方式建立连接:
ssh -i keypair.pem user@hostname.domain.com
Run Code Online (Sandbox Code Playgroud)
并且hostname.domain.com
同时具有 IPv4 和 Ipv6 地址,它会首先尝试通过 IPv6 连接,然后最终退回到 IPv4。
简单修复,强制它仅使用 IPv4。
ssh -4 -i keypair.pem user@hostname.domain.com
Run Code Online (Sandbox Code Playgroud)
或者直接通过IP地址连接
ssh -i keypair.pem user@30.40.50.60
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
98043 次 |
最近记录: |