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

本文讲述了OpenSSH8.7版本后不再默认支持ssh-rsa签名的问题,提供了解决方案:修改sshd_config中的配置项,接受ssh-rsa,重启sshd服务,以及在~/.ssh/config中添加配置和生成ed25519密钥以适应新版本要求。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

错误详情

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值