切换用户报错 su Module is unknown

1. 发现问题

安全加固后的虚拟机使用普通用户登陆,然后切换到 root 用户的时候有如下报错

1
2
3
$ su root
Password: 
su: Module is unknown

2. 查找错误

查看 /var/log/secure 文件有如下错误, 找不到库文件 pam_tally.so

1
2
3
4
# vim /var/log/secure
Apr 16 16:45:32 compute01 sshd[21311]: pam_unix(sshd:session): session opened for user vmuser by (uid=0)
Apr 16 16:45:34 compute01 su: PAM unable to dlopen(/usr/lib64/security/pam_tally.so): /usr/lib64/security/pam_tally.so: cannot open shared object file: No such file or directory
Apr 16 16:45:34 compute01 su: PAM adding faulty module: /usr/lib64/security/pam_tally.so

3. 解决办法

把 pam_tally2.so 链接到 pam_tally.so

1
# ln -s /lib64/security/pam_tally2.so /lib64/security/pam_tally.so
Licensed under CC BY-NC-SA 4.0
一个默默无闻的工程师的日常
Built with Hugo
主题 StackJimmy 设计