首页 > 其他分享 >解决 ssh 找不到对应主机密钥类型

解决 ssh 找不到对应主机密钥类型

时间:2023-03-29 09:03:50浏览次数:54  
标签:PubkeyAcceptedKeyTypes 主机 HostKeyAlgorithms rsa 算法 ssh 密钥

解决办法

如果最近升级到了 openssh 8.8 版,你会发现连接某些之前连接得好好的服务器突然无法连接:

Unable to negotiate with x.x.x.x port 2222: no matching host key type found. Their offer: ssh-rsa

解决办法是 ssh 命令指定算法:

ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa user@host -p 2222

上面比较麻烦,可以修改 ssh 配置文件 ~/.ssh/config,对于无法成功连接的 host,增加以下配置项:

HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa

完整的配置如下:

Host jump
    Port 2222
    HostName x.x.x.x
    User ***
    IdentityFile ~/.ssh/id_rsa
    UseKeychain yes
    AddKeysToAgent yes
    PreferredAuthentications publickey
    HostKeyAlgorithms +ssh-rsa
    PubkeyAcceptedKeyTypes +ssh-rsa

问题原因

根据 OpenSSH 8.8 Release Notes 信息:

This release disables RSA signatures using the SHA-1 hash algorithm
by default. This change has been made as the SHA-1 hash algorithm is
cryptographically broken, and it is possible to create chosen-prefix
hash collisions for <USD$50K [1]

For most users, this change should be invisible and there is
no need to replace ssh-rsa keys. OpenSSH has supported RFC8332
RSA/SHA-256/512 signatures since release 7.2 and existing ssh-rsa keys
will automatically use the stronger algorithm where possible.

Incompatibility is more likely when connecting to older SSH
implementations that have not been upgraded or have not closely tracked
improvements in the SSH protocol. For these cases, it may be necessary
to selectively re-enable RSA/SHA1 to allow connection and/or user
authentication via the HostkeyAlgorithms and PubkeyAcceptedAlgorithms
options. For example, the following stanza in ~/.ssh/config will enable
RSA/SHA1 for host and user authentication for a single destination host:

    Host old-host
        HostkeyAlgorithms +ssh-rsa
        PubkeyAcceptedAlgorithms +ssh-rsa

We recommend enabling RSA/SHA1 only as a stopgap measure until legacy
implementations can be upgraded or reconfigured with another key type
(such as ECDSA or Ed25519).

从这里可以知道,从 openssh 8.8 版本开始默认禁用了 ssh-rsa 算法,对于大部分情况,这次的更改是无感知的,当服务器仅支持 ssh-rsa 算法时才会出现不兼容的情况。

本地启用 RSA/SHA1 支持仅仅只是一种权宜之计,官方建议是升级密钥算法或使用另一种密钥算法(例如 ECDSA 或 Ed25519 算法)。

标签:PubkeyAcceptedKeyTypes,主机,HostKeyAlgorithms,rsa,算法,ssh,密钥
From: https://www.cnblogs.com/fatedeity/p/17267481.html

相关文章

  • 使用eNSP模拟器完成SSH
    写在前:在前面的Telnet实训中,如果你使用了Wireshark抓包软件,你会看见这样的画面,详见图1。图1出现上述图片情况,说明Telnet在数据传输过程中是明文传输。数据包发送过程中......
  • 修改sshd的侦听端口
    Linux默认的侦听端口是22,现在是需要修改为10022操作系统以Centos7.9为例:1. 编辑sshd配置文件vim/etc/ssh/sshd_config  2.调整Selinux,将侦听端口添加到sell......
  • centos系统 修改ssh默认端口号
    前提:关闭防火墙、关闭SELinux#关闭防火墙systemctlstopfirewalld&&systemctldisablefirewalld#关闭SElinux#永久关闭sed-i's/SELINUX=enforcing/SELIN......
  • java远程链接SSH,并执行命令
    远程连接SSh,可以配合webhook使用,自动打包处理,在docker部署下,是一种成本很小但是很实用的方案。本方案使用ssh2进行链接。正常来说有两种链接方式,这里选择startShell,这种方式......
  • 远程SSH连接和远程桌面连接龙芯3A5000
    远程SSH连接sudoaptupdate#更新软件列表sudoaptinstallopenssh-client#安装SSH客户端sudoaptinstallopenssh-server#安装SSH服务端sudosystemctlstart......
  • Grasshopper - Summation
    SummationWriteaprogramthatfindsthesummationofeverynumberfrom1tonum.Thenumberwillalwaysbeapositiveintegergreaterthan0.Forexample(Inp......
  • 好用的WordPress主机推荐
    在跨境电商领域,我们无论是做B2B传统外贸,还是B2C在线交易,网站是一个必备的媒介。那么,我们搭建网站除了用SaaS工具之外,我们还可以使用Wordpress虚拟主机。我通过我的亲身体......
  • 三丰云"免费虚拟主机"“免费云服务器”
    三丰云"免费虚拟主机"“免费云服务器”产品致力于为客户提供一流的云计算产品及服务,通过自主研发的云计算技术与产品为用户提供高性能、高安全性的云服务。三丰云平台的服务......
  • mysql jdbc 通过SSH Tunnel连接MySQL数据库
    1.pom.xml参考JDBC通过SSHTunnel连接MySQL数据库<dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifa......
  • 【A-005】基于SSH的校园网上订餐系统(含论文)
    开发环境:Eclipse/MyEclipse、Tomcat8、Jdk1.8数据库:MySQL项目介绍:为了顺应时代潮流的发展,便捷人民的生活,提高群众的生活质量,本系统应运而生。在了解了相关线上网上订餐......