pam_unix.so 成功登录时打印 "authentication failure"

pam_unix.so Prints "authentication failure" on Successful Login

/var/log/messages 显示类似

的消息
Jul  6 13:00:05 orbit-32 sshd[11517]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.98.106  user=admin

尽管我的密码验证成功并且我已登录。我正在使用带有 pam_unix.so 作为唯一插件的 PAM。怎么会这样?

如果您在 pam_unix 中启用 audit 登录并允许使用 syslog.conf 进行调试日志记录,您将看到以下内容:

 debug2: input_userauth_request: try method none [preauth]
 ...
 pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.98.106  user=admin

登录方法'none'原来是sshd尝试用空密码登录。这显然是 PAM 规范的一部分,有关详细信息,请参阅 http://www.gossamer-threads.com/lists/openssh/users/43558

要修复它,请在 sshd_config 中将 PermitEmptyPasswords 设置为 'no'。这将防止 sshd 尝试针对 PAM 使用空密码。