Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 12 min read

No Matching Host Key Type Found: Fix ssh-rsa Errors (2026)

You run ssh against an old switch, a NAS, an ESXi box or a server nobody has touched in years, and it refuses before it even asks for a password: Unable to negotiate with 10.0.0.5 port 22: no matching host key type fo

You run ssh against an old switch, a NAS, an ESXi box or a server nobody has touched in years, and it refuses before it even asks for a password:

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

The short fix is one line of ssh config, scoped to that one host: HostKeyAlgorithms +ssh-rsa. The real fix is on the server, and it's often smaller than people expect, because the problem usually isn't the RSA key at all.

This guide explains what the error means, gives the safe client-side workaround for ssh, scp, sftp and Git, and covers the sibling errors you'll hit on the same old hardware: ssh-dss, no matching key exchange method found and no matching cipher found. Every error message below was reproduced on a lab sshd (OpenSSH 9.6p1, Ubuntu 24.04) that was deliberately restricted to legacy algorithms, with an OpenSSH 9.6 client.

Quick Summary: What You'll Learn

  • What "no matching host key type found" means, and why Their offer: ssh-rsa is about SHA-1, not RSA keys.
  • The one-host config entry that fixes it without weakening every other connection.
  • The same fix for scp, sftp, Git and Windows.
  • How to fix ssh-dss, key exchange and cipher mismatches, and why DSA may not be fixable on a new client.
  • The server-side fix that lets you delete the workaround.

What does "no matching host key type found" mean?

At the start of every SSH connection, client and server each send lists of the algorithms they accept: key exchange methods, host key algorithms, ciphers and MACs. For each list there has to be at least one algorithm both sides accept. If there isn't, the client stops with Unable to negotiate with ... and names the list that failed.

"No matching host key type found" means the failing list is the host key algorithm: the method the server uses to prove its identity. Their offer: is the server's complete list. In the error above, the server can only prove its identity with ssh-rsa, and your client doesn't accept ssh-rsa by default.

That last part changed in OpenSSH 8.8, released 2021-09-26. Its release notes say it "disables RSA signatures using the SHA-1 hash algorithm by default", because SHA-1 is broken enough to allow chosen-prefix collisions. Every client built on OpenSSH 8.8 or newer behaves this way, which covers current Linux distributions and recent macOS releases. Run ssh -V to see which version you have.

The confusing part is the name. ssh-rsa is both the name of an RSA key type and the name of one signature algorithm: RSA with SHA-1. What OpenSSH disabled is the signature algorithm. RSA keys themselves are fine. The same release notes point out that OpenSSH has supported RSA signatures with SHA-256 and SHA-512 (rsa-sha2-256, rsa-sha2-512, RFC 8332) since release 7.2, and that existing RSA keys use them automatically where possible.

The lab shows this directly. With the server using the same RSA host key but with default settings, a 9.6 client connected without any changes:

debug1: kex: host key algorithm: rsa-sha2-512
debug1: Server host key: ssh-rsa SHA256:eUM1eM53WGp4e+ux279euEU5nwIGi7C9e0XV5aIGyNA
Authenticated to 127.0.0.1 ([127.0.0.1]:2299) using "publickey".

Same key, different signature algorithm. So when you see Their offer: ssh-rsa with nothing else in the list, the server's SSH software is old enough (or configured narrowly enough) that it can only sign with SHA-1.

How do you fix it for one host without weakening everything?

Add the algorithm back for that host only. On the command line, to test:

ssh -o HostKeyAlgorithms=+ssh-rsa [email protected]

The + matters. The ssh_config(5) man page says that when the list "begins with a '+' character, then the specified signature algorithms will be appended to the default set instead of replacing them." Without the +, you'd replace your whole list with ssh-rsa alone. With it, your client still prefers modern algorithms and only falls back to ssh-rsa when the server offers nothing better. In the lab, the +ssh-rsa connection went through with:

debug1: kex: host key algorithm: ssh-rsa
Authenticated to 127.0.0.1 ([127.0.0.1]:2299) using "publickey".

Once it works, make it permanent in ~/.ssh/config, inside a Host block for that device:

Host oldswitch
    HostName 10.0.0.5
    User admin
    HostKeyAlgorithms +ssh-rsa
    PubkeyAcceptedAlgorithms +ssh-rsa

This is the same stanza the OpenSSH 8.8 release notes recommend for "a single destination host", and they're explicit that it's "a stopgap measure until legacy implementations can be upgraded or reconfigured".

Two rules keep it from leaking to other hosts:

  • Never put it under Host *. That re-enables SHA-1 signatures for every server you connect to, including ones that support better algorithms. A man-in-the-middle can't force a downgrade below what both sides accept, but there's no reason to widen what you accept everywhere.
  • Put specific blocks above general ones. ssh_config uses the first value it finds for each option: "more host-specific declarations should be given near the beginning of the file, and general defaults at the end." If you have a lot of hosts, our guide to organizing your ssh config file covers a layout that keeps legacy exceptions in one place.

Check what ssh will actually use for a host with ssh -G, which prints the configuration after evaluating Host and Match blocks:

ssh -G oldswitch | grep -i '^hostkeyalgorithms'

ssh-rsa should appear at the end of the list for oldswitch, and not at all for any other host name. In the lab, ssh -G newbox with the same config file showed no ssh-rsa.

Why do you also need PubkeyAcceptedAlgorithms?

HostKeyAlgorithms covers the server proving who it is. PubkeyAcceptedAlgorithms covers you proving who you are with a key. An old server that can only verify RSA signatures with SHA-1 will reject the SHA-2 signature your client sends for your RSA key.

That failure looks different, because the connection itself succeeds. In the lab, with the server's PubkeyAcceptedAlgorithms set to ssh-rsa only and an RSA user key, ssh -v showed:

debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-rsa>
debug1: Skipping ssh-rsa key /home/you/.ssh/id_rsa - corresponding algorithm not supported by server
[email protected]: Permission denied (publickey).

Adding -o PubkeyAcceptedAlgorithms=+ssh-rsa made the same key work. If your key on that device is Ed25519, this option won't help: the device has to support Ed25519, and very old ones don't. That's why the stanza above sets both options. A plain Permission denied (publickey) has many other causes, so read the -v output before adding options.

How do you fix it for scp, sftp, Git and Windows?

scp and sftp run ssh underneath, so they fail with the same message. From the lab, sftp without the fix:

Unable to negotiate with 127.0.0.1 port 2299: no matching host key type found. Their offer: ssh-rsa
Connection closed

Both read ~/.ssh/config, so a Host block fixes them too. For a one-off, pass the option with -o. Note that scp uses a capital -P for the port:

scp -o HostKeyAlgorithms=+ssh-rsa backup.tar [email protected]:/tmp/
sftp -o HostKeyAlgorithms=+ssh-rsa [email protected]

Git over SSH uses your ssh config as well, so a Host block for the Git server's hostname is enough. If you need it for one repository only, Git's core.sshCommand setting replaces the ssh command it runs:

git config core.sshCommand "ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa"

Major hosted Git services support modern algorithms, so if you see this error against one of them, check that the hostname actually points where you think it does before you downgrade anything.

Windows: the OpenSSH client built into Windows 10 and 11 reads %USERPROFILE%\.ssh\config and takes the same options. Whether you hit the error at all depends on its version (ssh -V), since the change arrived in OpenSSH 8.8. Create the file if it doesn't exist (no extension) and add the same Host block. The -o flags work the same in PowerShell.

What about "Their offer: ssh-dss"?

ssh-dss is DSA. Same error, worse news:

Unable to negotiate with 127.0.0.1 port 2299: no matching host key type found. Their offer: ssh-dss

DSA host and user keys were disabled by default in OpenSSH 7.0 (2015). On a 9.6 client, HostKeyAlgorithms +ssh-dss still works, and it did in the lab. But OpenSSH 10.0 (released 2025-04-09) "removes support for the weak DSA signature algorithm" entirely. A client on 10.0 or later has nothing left to re-enable.

Check your client version with ssh -V. If it's 10.0 or newer and the device only offers ssh-dss, your options are to update the device's firmware, to reach it through a jump host that still runs an older client, or to use an older client in a throwaway container or VM for that one job. None of these are great, and that's the point: a device that only speaks DSA in 2026 is overdue for replacement or at least a firmware update.

How do you fix "no matching key exchange method found"?

Same pattern, different list. A server that only offers 1024-bit Diffie-Hellman:

Unable to negotiate with 127.0.0.1 port 2299: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1,ext-info-s,[email protected]

Ignore ext-info-s and [email protected]. Those are protocol markers a modern sshd adds to its list, not key exchange methods you can pick. The real offer is diffie-hellman-group1-sha1, which OpenSSH disabled by default in 7.0. The OpenSSH legacy options page says it's weak and "within theoretical range of the so-called Logjam attack". The fix is again + in a host block:

Host oldswitch
    KexAlgorithms +diffie-hellman-group1-sha1

In the lab, the 9.6 client also refused diffie-hellman-group14-sha1 by default (its default list only has diffie-hellman-group14-sha256 from that family), and KexAlgorithms +diffie-hellman-group14-sha1 fixed it the same way.

You can also hit this error from the other direction: a modern server that someone hardened by hand, connecting from an old client. If the offer lists only post-quantum or Curve25519 methods, the client is the old side. Our post on the post-quantum key exchange warning covers why you shouldn't strip modern methods out of a server's KexAlgorithms to fix a warning.

How do you fix "no matching cipher found"?

Old devices often only speak CBC-mode ciphers, which current OpenSSH clients don't offer by default:

Unable to negotiate with 127.0.0.1 port 2299: no matching cipher found. Their offer: aes128-cbc
Host oldswitch
    Ciphers +aes128-cbc

That connected in the lab and negotiated aes128-cbc. Use the exact name from Their offer:. To see everything your client can do (including algorithms that are compiled in but off by default), use ssh -Q:

ssh -Q key      # host and user key types
ssh -Q kex      # key exchange methods
ssh -Q cipher   # ciphers
ssh -Q mac      # MACs

If the server's offer isn't in ssh -Q output at all, no option will help: your client was built without it or it has been removed, as with DSA in 10.0.

A device with all three problems ends up with a block like this:

Host oldswitch
    HostName 10.0.0.5
    User admin
    HostKeyAlgorithms +ssh-rsa
    PubkeyAcceptedAlgorithms +ssh-rsa
    KexAlgorithms +diffie-hellman-group1-sha1
    Ciphers +aes128-cbc

Add only the lines the error messages ask for. Each one is a weakness you're accepting for that host, so keep the list as short as the device allows.

What is the real fix on the server?

The client-side entry is a workaround. The fix is making the server offer something modern, so you can delete the exceptions.

If the server runs OpenSSH 7.2 or newer and still offers only ssh-rsa, it has been configured that way. Look for a HostKeyAlgorithms line in /etc/ssh/sshd_config and in any file under /etc/ssh/sshd_config.d/, and remove it. Then check the effective config and reload:

sudo sshd -T | grep -i hostkeyalgorithms
sudo sshd -t && sudo systemctl reload ssh

On Ubuntu and Debian the service is ssh; on RHEL-family systems it's sshd. Keep your current session open and test a new connection from a second terminal before you close it.

If the server lacks a modern host key, generate the missing ones:

sudo ssh-keygen -A

Per ssh-keygen(1), -A generates host keys of all default key types "if they do not already exist", with the default paths. Make sure sshd_config doesn't pin HostKey to only the RSA file; if it lists HostKey lines, add the Ed25519 one (/etc/ssh/ssh_host_ed25519_key). Our ssh-keygen best practices guide covers why Ed25519 is the default choice.

If the server is an appliance (switch, router, storage, hypervisor, BMC), you can't edit its sshd. Check the vendor's release notes for a firmware version that adds rsa-sha2-256/rsa-sha2-512, ECDSA or Ed25519 host keys. Until then, keep the client exception scoped to that device and, if you can, limit which networks can reach its management port.

After the server changes, expect a host key prompt. If the server now presents a different key than the one your client saved (a rebuilt device, regenerated keys), you'll get a host key change warning on the next connection. That's correct behaviour, not a bug: verify the new fingerprint on the device itself with ssh-keygen -lf /etc/ssh/ssh_host_*_key.pub before you accept it. Our post on SSH host key verification explains what to compare and why skipping it defeats the point.

Where does termique fit?

termique is a native SSH manager for macOS, Windows, Linux, iOS and Android. It doesn't remove the need to fix old devices, and we don't claim it connects to every legacy algorithm: if a device only speaks DSA, the right answer is still firmware or replacement.

Where it helps is the part around the fix. termique saves each server's host key on first connect and blocks the connection before sending any credential if the key changes later, showing the new key's type and its SHA256: fingerprint in the same format as OpenSSH. So when you upgrade an appliance and its key changes, you compare that fingerprint with ssh-keygen -lf on the device and confirm it with your master password. You can also generate an Ed25519 key in termique's SSH keys view and install it on hosts, and private keys and passwords sync between your devices end-to-end encrypted. Host names, groups and snippets sync as plain metadata, so the server never sees your credentials, only where you connect.

If you manage a mix of new servers and old gear, download termique and try it on the new ones first.

FAQ

Is it safe to add HostKeyAlgorithms +ssh-rsa?

For one specific legacy host, it's an accepted stopgap: OpenSSH's own release notes suggest exactly this stanza. It accepts SHA-1 signatures from that host, which is weaker than the default. Don't add it under Host *, and remove it once the device supports rsa-sha2-256 or rsa-sha2-512.

Do I need to replace my RSA key?

Usually not. RSA keys work with SHA-2 signatures (rsa-sha2-256, rsa-sha2-512), which OpenSSH has supported since 7.2. The error is about the SHA-1 signature algorithm the old server insists on. If you're generating a new key anyway, Ed25519 is the better default.

Why does scp fail with "no matching host key type found" when ssh works?

A common reason: ssh is reading a Host alias that has the fix, while scp is called with the raw IP or a different name that doesn't match the block. Use the same alias in both, or pass -o HostKeyAlgorithms=+ssh-rsa to scp.

Why does +ssh-dss not work anymore?

OpenSSH 10.0 removed DSA support completely. Older clients can still re-enable it with HostKeyAlgorithms +ssh-dss; 10.0 and later can't. Check ssh -V and ssh -Q key: if ssh-dss isn't listed, your client can't speak it.

What does "Unable to negotiate with" mean?

It means the client and server have no algorithm in common for one of the negotiated lists. The rest of the message tells you which one: host key type, key exchange method, cipher or MAC, and Their offer: lists what the server supports.

For the bigger picture of keys, hardening and access control, see our complete guide to SSH security.

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.