赞
踩
上一篇“【OpenSSH升级】无论密码输入正确与否总是登录失败(error: Could not get shadow information for root)”总结了CentOS7上的openssh从7.4升级到9.4之后,密码认证失败问题,这里再总结一下证书认证失效问题。
大多数情况下,可能遇不到这个问题,因为我将root用户锁了(也就是密码肯定用不了),然后sshd_config配置为证书和密码认证均可:
- PubkeyAuthentication yes
- AuthorizedKeysFile .ssh/authorized_keys
-
- PasswordAuthentication yes
突然发现,证书认证失效了,还以为是如下问题(便使用ssh-ed25519重新生成秘钥进行配置,但是仍然无法成功登录):
=========================================================================
1、使用ssh-rsa加密算法报错
userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]
2、网上很多说在sshd_config中配置中增加ssh-rsa的支持,但是并不生效:
PubkeyAcceptedAlgorithms +ssh-rsa
解决:使用加密算法(默认生成到~/.ssh
ssh-keygen -t ssh-ed25519
cat id_ed25519.pub >>authorized_keys
将id_ed25519下载到客户端进行配置。以securecrt为例:
新建会话,右键Properties-SSH2-Authentication-PublicKey(选中)-Properties(右侧),Public Key Properties的弹出面板中选则“Use session public key setting”,下方选择下载到客户端本地的Public Key 文件。
=========================================================================
最后只能查看查看系统日志(遇到问题,直接查看问题日志,而不是瞎猜 ---此乃解决问题的金科玉律):
2023-12-01T16:40:10.371531+08:00|info|sshd[2517662]|User root not allowed because account is locked
2023-12-01T16:40:10.617750+08:00|info|sshd[2517662]|userauth_pubkey: signature algorithm ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]
2023-12-01T16:40:16.472316+08:00|err|sshd[2517662]|error: Could not get shadow information for NOUSER
2023-12-01T16:40:16.498786+08:00|info|sshd[2517662]|Failed password for invalid user root from 192.168.xx.xxx port 22123 ssh2
2023-12-01T16:40:18.346792+08:00|err|sshd[2517662]|error: Received disconnect from 192.168.14.103 port 22123:14: Unable to authenticate using any of the configured authentication methods. [preauth]
2023-12-01T16:40:18.347086+08:00|info|sshd[2517662]|Disconnected from invalid user root 192.168.14.103 port 22123 [preauth]
上述日志一眼开门的解释,果断解锁root用户:usermod -U root,再次登录认证成功。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。