ssh登陆慢的深度排查

  • Post author:
  • Post category:其他


遇到一台服务器登陆比较慢,网上常见的方法,包括修改

UseDNS no



GSSAPIAuthentication no

都没有效果,

ssh -vvv [主机]

显示卡在

debug1: Offering public key: /root/.ssh/id_dsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply  
# 卡住N秒

网上有说是DNS解析问题,但抓包也没发现有dns请求。

方法一:删除

/root/.ssh/id_dsa

,可以解决,但对免密码登陆有影响。

方法二:详见 https://tanelpoder.com/posts/troubleshooting-linux-ssh-logon-delay-always-takes-10-seconds/

总结起来:


  1. strace -r -T -f -p [sshd进程号]
  2. 登陆,看sshd服务卡在哪个位置,一般是等待某个连接的响应(poll等待某个fd)
  3. 根据上一步的fd,向上查找fd创建的日志,一般是connect生成
  4. 根据上一步上下文信息,可能就能定位到故障原因了。文件是DNS,我遇到是跟

    nslcd

    服务的交互卡住了,这个服务不知道什么用,禁掉服务就正常了。



版权声明:本文为rainharder原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。