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
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.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.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-rsaNow
ssh old-switchworks, and so doscpandsftpto it. Don't put these lines underHost *: that would accept SHA-1 from every server.
Using an older ssh?
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:
| The error says | Add |
|---|---|
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 -Acreates 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
- SSH config file examplesWhere ~/.ssh/config lives on each system, how ssh reads it, and copy-ready examples for aliases, ports, keys, jump hosts and keep-alives.Read the guide
- Passwordless SSH with keysMake an SSH key, copy it to the server with ssh-copy-id (or one PowerShell line on Windows), get the permissions right and sign in without a password.Read the guide
- SSH port 22SSH and SFTP use port 22. Connect on another port with ssh -p, change the port on a Linux or Windows server, and check it's open.Read the guide
- SSH to a Linux serverConnect to a Linux server from Windows or another Linux machine, check its key, and copy files.Read the guide
- SSH & SFTP clientTerminal tabs, an SFTP and FTP file manager, key sign-in and one command to every server.Learn more
- pfSense, OPNsense and router adminKeep firewall and router admin pages off the internet and still reach them: web panels, a PC on the LAN, SSH and serial consoles.Read the guide
