Jan 21 09:49:05 localhost sshd[44946]: User tomcat not allowed because account is locked
Jan 21 09:49:05 localhost sshd[44946]: input_userauth_request: invalid user tomcat [preauth]
Jan 21 09:49:11 localhost sshd[44946]: Connection closed by 192.168.2.250 [preauth]
通过日志查看,刚开始以为是 Tomcat用户被锁定了:
=============== linux 用户解锁 =====================
查看用户:pam_tally2 --user 账号
解锁用户:pam_tally2 -r -u 账号
通过pam_tally2 --user指令发现没有锁定,最终通过查找资料是sshd没有开启 PAM
PAM is not enabled for SSH service, it is commented or set to "no" explicitly:
~# grep UsePAM /etc/ssh/sshd_config
#UsePAM yes
开启sshd_config UsePAM yes;service sshd restart 出现新的问题,普通用户无法登陆
cd /etc/pam.d;ls -l sshd 查看此文件是否存在,没有则需创建
#%PAM-1.0
auth required pam_sepermit.so
auth include password-auth
account required pam_nologin.so
account include password-auth
password include password-auth
# pam_selinux.so close should be the first session rule
session required pam_selinux.so close
session required pam_loginuid.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session required pam_selinux.so open env_params
session optional pam_keyinit.so force revoke
session include password-auth 重新开启 UsePAM yes;service sshd restart成功解决问题!