首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >慢ssh登录-激活org.freedesktop.login1超时

慢ssh登录-激活org.freedesktop.login1超时
EN

Server Fault用户
提问于 2015-07-21 14:21:37
回答 2查看 36.4K关注 0票数 44

在我的服务器上,我注意到SSH登录确实延迟了。

使用ssh -vvv选项连接时,延迟发生在debug1: Entering interactive session.

连接的摘录:

代码语言:javascript
复制
debug1: Authentication succeeded (publickey).
Authenticated to IP_REDACTED ([IP_REDACTED]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: packet_set_tos: set IP_TOS 0x10
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1

使用概述这里的方法,我生成了strace输出,并注意到行14:09:53.676004 ppoll([{fd=5, events=POLLIN}], 1, {24, 999645000}, NULL, 8) = 1 ([{fd=5, revents=POLLIN}], left {0, 0}) <25.020764>需要25秒。

斯特拉斯输出的提取:

代码语言:javascript
复制
14:09:53.675567 clock_gettime(CLOCK_MONOTONIC, {4662549, 999741404}) = 0 <0.000024>
14:09:53.675651 recvmsg(5, {msg_name(0)=NULL, msg_iov(1)=[{"l\4\1\1\n\0\0\0\2\0\0\0\215\0\0\0\1\1o\0\25\0\0\0", 24}], msg_controll
en=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 24 <0.000024>
14:09:53.675744 recvmsg(5, {msg_name(0)=NULL, msg_iov(1)=[{"/org/freedesktop/DBus\0\0\0\2\1s\0\24\0\0\0"..., 146}], msg_controllen
=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 146 <0.000025>
14:09:53.675842 recvmsg(5, 0x7ffe0ff1dfa0, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = -1 EAGAIN (Resource temporarily unavailab
le) <0.000023>
14:09:53.675925 clock_gettime(CLOCK_MONOTONIC, {4662550, 96075}) = 0 <0.000024>
14:09:53.676004 ppoll([{fd=5, events=POLLIN}], 1, {24, 999645000}, NULL, 8) = 1 ([{fd=5, revents=POLLIN}], left {0, 0}) <25.020764>
14:10:18.696865 recvmsg(5, {msg_name(0)=NULL, msg_iov(1)=[{"l\3\1\0013\0\0\0\3\0\0\0m\0\0\0\6\1s\0\5\0\0\0", 24}], msg_controllen=0,     msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 24 <0.000017>
14:10:18.696944 recvmsg(5, {msg_name(0)=NULL, msg_iov(1)=[{":1.10\0\0\0\4\1s\0#\0\0\0org.freedesktop."..., 155}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 155 <0.000018>

我注意到在相关的时候在auth日志中有一个条目:

代码语言:javascript
复制
Jul 21 14:10:18 click sshd[8165]: pam_systemd(sshd:session): Failed to create session: Activation of org.freedesktop.login1 timed out

对此还不太清楚,它想要投票的是什么,为什么现在在这个特定的服务器上花了25秒。

journalctl -u systemd-logind命令显示

代码语言:javascript
复制
Jul 20 11:33:06 click systemd-logind[19415]: Failed to abandon session scope: Transport endpoint is not connected
Jul 21 05:04:54 myhost systemd[1]: Started Login Service.
Jul 21 12:15:30 myhost systemd[1]: Started Login Service.
Jul 21 12:17:04 myhost systemd[1]: Started Login Service.
Jul 21 12:49:55 myhost systemd[1]: Started Login Service.
Jul 21 13:57:05 myhost systemd[1]: Started Login Service.
Jul 21 13:58:49 myhost systemd[1]: Started Login Service.
Jul 21 14:01:55 myhost systemd[1]: Started Login Service.
Jul 21 14:08:32 myhost systemd[1]: Started Login Service.
Jul 21 14:09:53 myhost systemd[1]: Started Login Service.
Jul 21 14:19:08 myhost systemd[1]: Started Login Service.
Jul 21 14:21:26 myhost systemd[1]: Started Login Service.
Jul 21 14:22:37 myhost systemd[1]: Started Login Service.
Jul 21 14:25:20 myhost systemd[1]: Started Login Service.
Jul 21 14:30:27 myhost systemd[1]: Started Login Service.
Jul 21 15:02:56 myhost systemd[1]: Started Login Service.

发出命令systemctl restart systemd-logind.service修复它(目前可能是这样)。

它提到的Activation of org.freedesktop.login1是什么?有什么办法可以避免以后不得不重新启动logind吗?我希望随着时间的推移,我管理的其他服务器都会出现这个问题。

刚刚注意到这开始发生在另一台服务器上。

代码语言:javascript
复制
$ sudo service systemd-logind status

● systemd-logind.service - Login Service
   Loaded: loaded (/lib/systemd/system/systemd-logind.service; static)
   Active: active (running) since Tue 2015-06-16 14:10:57 BST; 1 months 12 days ago
     Docs: man:systemd-logind.service(8)
           man:logind.conf(5)
           http://www.freedesktop.org/wiki/Software/systemd/logind
           http://www.freedesktop.org/wiki/Software/systemd/multiseat
 Main PID: 1701 (systemd-logind)
   Status: "Processing requests..."
   CGroup: /system.slice/systemd-logind.service
           └─1701 /lib/systemd/systemd-logind

Jul 28 13:16:21 myhost systemd[1]: Started Login Service.
Jul 28 13:16:47 myhost systemd[1]: Started Login Service.
Jul 28 16:09:23 myhost systemd[1]: Started Login Service.
Jul 28 16:09:49 myhost systemd[1]: Started Login Service.
Jul 28 16:10:15 myhost systemd[1]: Started Login Service.
Jul 28 16:10:41 myhost systemd[1]: Started Login Service.
Jul 28 22:50:19 myhost systemd[1]: Started Login Service.
Jul 29 05:00:15 myhost systemd[1]: Started Login Service.
Jul 29 11:00:20 myhost systemd[1]: Started Login Service.
Jul 29 11:09:56 myhost systemd[1]: Started Login Service.

编辑-扩展的journalctl输出。

当注意到在另一台服务器上启动时,EDIT2添加了systemd-logind状态,如注释中所建议的。

更新-这开始发生在我的其他杰茜服务器。我是唯一一个经历这种事的人吗?除了重新启动系统之外,还有别的办法吗?有谁想过吗?

这个770135上有一个Debian报告。

EN

回答 2

Server Fault用户

发布于 2015-12-10 09:37:39

当dbus重新启动,而systemd没有重新启动时,就会发生这种情况。只需做以下几点:

代码语言:javascript
复制
systemctl restart systemd-logind

解决方案来自于这里:https://major.io/2015/07/27/very-slow-ssh-logins-on-fedora-22/

票数 52
EN

Server Fault用户

发布于 2017-06-14 07:46:14

使用:

代码语言:javascript
复制
systemctl restart systemd-logind

只能暂时解决问题。

解决方法之一是从cron作业中删除所有.scope文件,如声明的这里

代码语言:javascript
复制
* 2,14 * * * root /bin/rm -f /run/systemd/system/*.scope

相关的systemd bug报告在这里:范围单元泄漏减慢"systemctl列表-单元-文件“和延迟登录

它似乎实际上是一个dbus bug:unix在飞计数中断,它在dbus版本1.11.10中得到解决。

要永久修复此错误,只需等待dbus的此版本出现在您的发行版中即可。目前,Debian拉伸位于dbus 1.10.18,Ubuntu17.04(Z校)位于1.10.10,CentOS 7位于dbus 1.6.12。

票数 3
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/707377

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档