51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

远程ssh登录Ubuntu22.04系统时提示未注册

在安装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 ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,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

赞(12)
未经允许不得转载:工具盒子 » 远程ssh登录Ubuntu22.04系统时提示未注册