昨天需要ssh登录某服务器,但ssh登录缓慢,差不多半分钟才登录成功,故对其进行追踪检查

①、ssh ip -vvv 或 ssh ip -v

  用于检查ssh在哪个位置用时最长

  然后发现在Entering interactive session 语句后等待时间最长,超过20秒,说明非ssh登录时密 码验证的问题

②、这样看不出啥问题,故使用starce进行追踪

  starce -o ~/starce_ssh.txt -T ssh ip

  cat ~/starce_ssh.txt 发现:

   clock_gettime(0x7 /* CLOCK_??? */, {5243451, 134078578}) = 0 <0.000026>

   select(7, [3], [], NULL, NULL)          = 1 (in [3]) <25.026978>

   然而看不懂这个地方,悲催

③、故尝试查看所登录的服务器的messages日志,竟然有重大发现

  dbus[7782]: [system] Failed to activate service 'org.freedesktop.login1': timed out

  dbus-daemon: dbus[7782]: [system] Failed to activate service 'org.freedesktop.login1':   timed out

   显示这个服务超时了,网上查找资料,大意如下:

   dbus的服务重启后,systemd-logind服务没有重启导致,可以查看systemctl status systemd-logind的状态,解决方法就是重启该服务 systemctl restart systemd-logind


参考文档:http://serverfault.com/questions/707377/slow-ssh-login-activation-of-org-freedesktop-login1-timed-out