Guide

How to fix SSH error: no matching host key type found (their offer: ssh-rsa)

"no matching host key type found. Their offer: ssh-rsa" means the server can only identify itself with an old SHA-1 ssh-rsa signature, which ssh has refused by default since OpenSSH 8.8. To connect anyway, allow it for that one host: ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa user@host.

Below: how to make that permanent for the one device without weakening every other connection, the matching fixes for the rest of the "Unable to negotiate" family, and the real fix on the device itself.

  • One host only
  • ssh, scp and sftp
  • Key exchange and cipher errors too

Updated · OpenSSH 8.8 and later on Linux, macOS and Windows

Why the error appears

Every SSH server proves its identity with a host key. Old SSH servers, and the firmware in many older switches, routers, NAS boxes and server management cards, only sign with ssh-rsa, which uses SHA-1. SHA-1 is no longer considered safe, so OpenSSH 8.8 and later leave it out of what they accept. Newer servers use rsa-sha2-256, rsa-sha2-512, ECDSA or Ed25519 instead, and never show this error.

Nothing is broken on your side. An older computer whose ssh predates 8.8 may still connect to the same device, because it still has the old default.

Step-by-step: connect to an old device that offers ssh-rsa

  1. Step 1: Try it for one connection

    ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa admin@192.168.1.2

    The + adds ssh-rsa to the list ssh accepts, keeping everything else. The second option only matters if you sign in with an RSA key; with a password, the first is enough.

  2. Step 2: Check the fingerprint the first time

    As with any new server, ssh shows the device's key fingerprint. Compare it with the one in the device's admin page or console before you type yes.

  3. Step 3: Save it for that device only

    Add a Host entry to your SSH config file, so the exception applies to this device and nothing else:

    Host old-switch
        HostName 192.168.1.2
        User admin
        HostKeyAlgorithms +ssh-rsa
        PubkeyAcceptedAlgorithms +ssh-rsa

    Now ssh old-switch works, and so do scp and sftp to it. Don't put these lines under Host *: that would accept SHA-1 from every server.

Using an older ssh?

ssh versions before 8.5 don't know PubkeyAcceptedAlgorithms (it was called PubkeyAcceptedKeyTypes) and stop with "Bad configuration option". They still accept ssh-rsa by default, so leave both lines out there. ssh -V shows your version.

The other Unable to negotiate errors

Old devices often lack other modern algorithms too. The error says what's missing and what the server offers; add that offer with the matching option, the same way:

SSH negotiation errors and the option that allows the server's offer
The error saysAdd
no matching host key type found. Their offer: ssh-rsa-o HostKeyAlgorithms=+ssh-rsa
no matching key exchange method found. Their offer: diffie-hellman-group1-sha1-o KexAlgorithms=+diffie-hellman-group1-sha1
no matching cipher found. Their offer: aes128-cbc,3des-cbc-o Ciphers=+aes128-cbc
sign_and_send_pubkey: no mutual signature supported-o PubkeyAcceptedAlgorithms=+ssh-rsa

Use the exact name from Their offer: if the device offers several, pick the strongest one listed. In a config file the same settings go under the device's Host entry without the -o and the =, for example KexAlgorithms +diffie-hellman-group1-sha1. ssh -Q key, ssh -Q kex and ssh -Q cipher list what your ssh supports at all.

Their offer: ssh-dss is a DSA host key. Recent OpenSSH releases have dropped DSA entirely, so no option brings it back: update the device's firmware or have it make a new RSA or ECDSA host key.

The lasting fix: update the server or device

  • Check for a firmware or software update for the switch, router, NAS or management card. Most current releases use SHA-2 signatures.
  • On a Linux server with an old SSH server, update the openssh-server package. If it lacks modern host keys, sudo ssh-keygen -A creates any of the default ones that are missing; restart SSH afterwards.
  • If the device can't be updated, keep it on a management network and use the per-host exception above, never a global one.

Debugging something else? ssh -v user@host prints the whole negotiation, including what each side offered. For connections refused before negotiation even starts, check the SSH port and that the SSH server is running.

Keep your old and new devices in one list

If you look after a mix of servers and network gear, the RemoteAccessApp SSH client keeps them as saved hosts with tabs, SFTP and key sign-in, and checks each server's key fingerprint the first time, refusing a key that later changes. It's free for up to 5 saved hosts on Windows and Linux: download RemoteAccessApp. Moving your ssh setup across? It can import your SSH config file.

Questions, answered

Related