在安装Ubuntu22.04版本系统后,使用rsa密钥远程登录发现提示密钥未注册。
查看ssh版本

root@lolicp:~# ssh -V
OpenSSH_8.9p1 Ubuntu-3ubuntu0.7, OpenSSL 3.0.2 15 Mar 2022

通过日志发现当前ssh版本不支持ssh-rsa加密方式:

root@lolicp:~# tail -f /var/log/auth.log
Jul 11 20:19:57 lolicp sshd[3709]: userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]
Jul 11 20:20:08 lolicp sshd[3709]: message repeated 3 times: [ userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]]

解决问题

查看支持的密钥算法

通过查看sshd可以接受的密钥算法,发现不存在ssh-rsa

root@lolicp:~# sshd -T | egrep "pubkey"
pubkeyauthentication yes
pubkeyacceptedalgorithms [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256
pubkeyauthoptions none
生成新密钥

指定生成ed25519类型的密钥

ssh-keygen -t ed25519
支持旧密钥

如果旧密钥要求支持的话,可以添加对于密钥类型。

echo "PubkeyAcceptedAlgorithms +ssh-rsa" >> /etc/ssh/sshd_config

参考文档:https://blog.csdn.net/ljz0929/article/details/129759705

END

本文标题:远程ssh登录Ubuntu22.04系统时提示未注册

本文作者:宇宙最帅的男人

本文链接:https://lolicp.com/ssh/202411686.html

版权声明:转载或者引用本文内容请注明来源及原作者,本文著作权归 (lolicp.com) 所有。

除非另有说明,本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

最后修改:2024 年 07 月 11 日
如果觉得我的文章对你有用,请随意赞赏