今天遇到个可郁闷的问题,帮别人克隆了一条Linux虚拟机,结果启动时登录不了,输入忘密码一直提示输入用户名—密码,进入死循环了,但是ssh是可以进去的,单用户也是可以的。但是tty登录就是死循环。
1.开始判断以为是密码有问题,所有进入单用户把密码重置了,结果还是死循环进不了系统,最后还是进单用户看日志,发现有个pam验证模块是有问题的:
[root@test007 ~]# tail -f /var/log/secure
Mar 16 16:41:45 test007 login: PAM unable to dlopen(/lib/security/pam_limits.so)
Mar 16 16:41:45 test007 login: PAM [dlerror: /lib/security/pam_limits.so: cannot open shared object file: No such file or directory]
Mar 16 16:41:45 test007 login: PAM adding faulty module: /lib/security/pam_limits.so
Tty登录提示如下:
 


2.找到日志里提示的模块,发现在模块在session里,禁用掉以后重启系统。
[root@test007 ~]# cat /etc/pam.d/login
#%PAM-1.0
auth       required     pam_securetty.so
auth       required     pam_stack.so service=system-auth
auth       required     pam_nologin.so
account    required     pam_stack.so service=system-auth
password   required     pam_stack.so service=system-auth
# pam_selinux.so close should be the first session rule
session    required     pam_selinux.so close
session    required     pam_stack.so service=system-auth
session    required     pam_loginuid.so
session    optional     pam_console.so
#session    required    /lib/security/pam_limits.so        ---禁用掉该模块
# pam_selinux.so open should be the last session rule
session    required     pam_selinux.so open

[root@test007 ~]#
3.系统重启后tty登录正常,安全日志显示正常登录。
[root@test007 ~]# tail -f /var/log/secure
Mar 16 16:41:45 test007 login: PAM unable to dlopen(/lib/security/pam_limits.so)
Mar 16 16:41:45 test007 login: PAM [dlerror: /lib/security/pam_limits.so: cannot open shared object file: No such file or directory]
Mar 16 16:41:45 test007 login: PAM adding faulty module: /lib/security/pam_limits.so
Mar 16 16:42:02 test007 login: PAM unable to dlopen(/lib/security/pam_limits.so)
Mar 16 16:42:02 test007 login: PAM [dlerror: /lib/security/pam_limits.so: cannot open shared object file: No such file or directory]
Mar 16 16:42:02 test007 login: PAM adding faulty module: /lib/security/pam_limits.so
Mar 16 08:50:55 test007 sshd[3542]: Server listening on :: port 22.
Mar 16 08:50:55 test007 sshd[3542]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.
Mar 16 16:49:48 test007 sshd[5404]: Accepted password for root from ::ffff:192.168.213.234 port 4595 ssh2
Mar 16 08:49:48 test007 sshd[5405]: Accepted password for root from ::ffff:192.168.213.234 port 4595 ssh2