通过ssh -vv sysop@ip登录发现
卡在
debug1: pledge: network
查看日志,
#less /var/log/secure
发现如下报错
sshd[2721]: pam_systemd(sshd:session): Failed to create session: Connection timed out
问题主要是dbus导致system报错超时,最终由system -logind服务导致ssh,su,nfs,samba,ftp等服务超时不在相应。
由于模块org.freedesktop.login1不能由systemd启动,会导致登录ssh时间缓慢,或者无法登陆等一些情况。
问题发生时我们可以通过如下命令看到可能 systemd-logind 无法创建process或者链接的信息
#busctl
NAME PID PROCESS USER CONNECTION UNIT SESSION DESCRIPTION
org.freedesktop.login1 875 systemd-logind root :1.1 systemd-logind.service - -
解决方法:
This is probably an issue with D-Bus and systemd. If the dbus service is restarted for some reason, you will also need to restart systemd-logind.
#D-Bus是一个为应用程序间提供通信的消息总线系统, 用于进程之间的通信。
#centos日志在/var/log/secure
sshd[2721]: pam_systemd(sshd:session): Failed to create session: Connection timed out
If yes, just restart systemd-logind service:
systemctl restart systemd-logind