CENTOS 升级SSH至8.0P1 用户无法登录Permission denied (publickey,password,keyboard-interactive)
问题前奏
有个客户环境的SSH 版本为 OpenSSH_8.0p1, OpenSSL 1.0.2r 26 Feb 2019
。且用jsch的0.1.54版本连接出错。为尝试复现问题,先在自己虚拟机上升级环境。
升级步骤参考: https://www.cnblogs.com/nmap/p/10779658.html 。 升级过程无误可用。
问题情况
升级完成后,出现SSH远程登录失败,输入三次密码后报如下错误:
Permission denied (publickey,password,keyboard-interactive).
问题分析解决
-
百度清一色都是这样的解答,说是证书问题。https://bbs.csdn.net/topics/380148805 。 显然我没通过它解决。
-
查看sshd服务的status试试:
[root@gxp5 etc]# service sshd status ● sshd.service - SYSV: OpenSSH server daemon Loaded: loaded (/etc/rc.d/init.d/sshd; bad; vendor preset: enabled) Active: active (running) since 五 2020-07-17 11:29:50 CST; 33s ago Docs: man:systemd-sysv-generator(8) Process: 11371 ExecStop=/etc/rc.d/init.d/sshd stop (code=exited, status=0/SUCCESS) Process: 11380 ExecStart=/etc/rc.d/init.d/sshd start (code=exited, status=0/SUCCESS) Main PID: 11388 (sshd) Tasks: 1 CGroup: /system.slice/sshd.service └─11388 /usr/sbin/sshd 7月 17 11:29:50 gxp5 systemd[1]: Starting SYSV: OpenSSH server daemon... 7月 17 11:29:50 gxp5 sshd[11388]: Server listening on 0.0.0.0 port 22. 7月 17 11:29:50 gxp5 sshd[11388]: Server listening on :: port 22. 7月 17 11:29:50 gxp5 sshd[11380]: Starting sshd:[ 确定 ] 7月 17 11:29:50 gxp5 systemd[1]: Started SYSV: OpenSSH server daemon. 7月 17 11:30:18 gxp5 sshd[11432]: error: Could not get shadow information for hundsun 7月 17 11:30:18 gxp5 sshd[11432]: Failed password for hundsun from 112.168.136.1 port 54594 ssh2 7月 17 11:30:20 gxp5 sshd[11432]: Failed password for hundsun from 112.168.136.1 port 54594 ssh2 7月 17 11:30:22 gxp5 sshd[11432]: Failed password for hundsun from 112.168.136.1 port 54594 ssh2
可以看到运行状态是正常的,但是登录失败,说是没有影子信息。
-
查看shadow information的问题
这里提到了UsePAM 选项变成了 no ,原来是yes 。 https://blog.csdn.net/weixin_30624825/article/details/99312372
我查看了一下我的/etc/ssh/sshd_config配置文件中,它是注释的,如下:
#UsePAM no
既然是注释的,我也不知道这个版本他的默认值是什么,那么我就改成yes试试,结果问题就解决了,远程可以登录了。
UsePAM
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
- 机器翻译
#将此设置为‘yes’,以启用PAM身份验证、帐户处理、和会话处理。如果启用了此功能,则PAM身份验证将通过挑战者esponseauthentication和# PasswordAuthentication被允许。根据您的PAM配置,通过挑战者esponseauthentication进行的PAM身份验证可以绕过“PermitRootLogin without-password”的设置。如果您只是想让PAM帐户和会话检查在没有 PAM身份验证的情况下运行,那么启用这个功能,但将PasswordAuthentication 和 质询响应身份验证 设置为“no”。
ps: 还不是很懂,先留个纪念
补充:https://developer.aliyun.com/ask/82869?spm=a2c6h.13706215.wenda.35.6f4940ae6pa3P1
这里提到了,如果ulimit参数修改没有生效,问题可能就是没有开启PAM。