ubuntu22.04 ssh连接失败 userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms

userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]
sshd[14785]: error: Received disconnect from xxxx port 45190:3: com.jcraft.jsch.JSchException: Auth fail [preauth]

OpenSSH从8.7以后版本开始默认不支持ssh-rsa签名的方式,需要手动设置

$ ssh -V
OpenSSH_8.9p1 Ubuntu-3ubuntu0.1, OpenSSL 3.0.2 15 Mar 2022

解决办法:
1.在/etc/ssh/sshd_config里面新增如下配置项
PubkeyAcceptedKeyTypes=+ssh-rsa

重启sshd

sudo systemctl restart sshd.service

2.在~/.ssh/config里面新增如下配置项

Host */or example.com

    PubkeyAcceptedAlgorithms +ssh-rsa

3.重新生成密钥支持格式的密钥

ssh-keygen -t ed25519

 

posted @ 2023-05-15 17:46  w_boy  阅读(872)  评论(0编辑  收藏  举报