If you see “no matching host key type found” when connecting over SSH, it means your SSH client and server cannot agree on a host key algorithm, usually because the server only offers older key types that the client has disabled by default. The fix is to explicitly allow the missing algorithm with the -oHostKeyAlgorithms= option or in your SSH config file.
What Causes This Error
SSH uses host keys to verify that you are connecting to the intended server. Over the years, several key algorithms have been deprecated because they use weak cryptography (like SHA-1). Modern OpenSSH clients (version 8.8 and later) disable the ssh-rsa (RSA with SHA-1) algorithm by default. If a server still only offers that algorithm, the client reports “no matching host key type found” and aborts the connection.
This commonly happens with older servers, network appliances, or embedded devices that have not been updated. The server may still support modern algorithms, but it might be misconfigured to only offer the old one. The error message usually includes the list of algorithms the server offers, for example:
Unable to negotiate with 192.0.2.10 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss
How to Fix It Temporarily
If you need to connect right now and you trust the server, you can tell the client to allow the missing algorithm on the command line. Replace user@host with your actual username and server address, and replace ssh-rsa with whatever algorithm the server offered.
- For one command:
ssh -oHostKeyAlgorithms=+ssh-rsa user@host - For SCP:
scp -oHostKeyAlgorithms=+ssh-rsa file user@host:/path/ - For SFTP:
sftp -oHostKeyAlgorithms=+ssh-rsa user@host
The plus sign before the algorithm name means “add this to the default list” rather than replacing it. This is safer because it keeps all the modern algorithms enabled.
Permanent Fix in SSH Config
If you connect to that server regularly, add the option to your ~/.ssh/config file. Create or edit the file and add a block like this:
Host myserver
HostName 192.0.2.10
User myusername
HostKeyAlgorithms +ssh-rsa
Now every time you run ssh myserver, it will use the added algorithm. You can also set it globally for all hosts, but that weakens security for every connection, so it is better to limit it to the specific server that needs it.
Why the Algorithm Is Disabled
The ssh-rsa algorithm uses the SHA-1 hash, which is considered cryptographically broken for collision attacks. While host key verification is not directly vulnerable to those attacks, the SSH community decided to phase out SHA-1 to future-proof the protocol. OpenSSH 8.8, released in 2021, disabled it by default. Other SSH implementations like PuTTY have also deprecated old algorithms, though they may still allow them with a warning.
If you are connecting to a server that only supports ssh-dss (DSA), that is even older and more insecure. DSA keys are limited to 1024 bits and are no longer recommended. In that case, you should strongly consider updating the server’s SSH configuration to use at least RSA with 2048 bits or an Ed25519 key.
How to Check What the Server Supports
You can see the algorithms a server offers without logging in by using the ssh-keyscan command:
ssh-keyscan -t rsa,ecdsa,ed25519 hostname
This lists the host keys of each type. If you see only ssh-rsa in the output, that explains the error. If you see modern types like ssh-ed25519 or ecdsa-sha2-nistp256, the server does support them, but your client might be configured to only try certain algorithms. In that case, check your client’s HostKeyAlgorithms setting in ~/.ssh/config or the system-wide /etc/ssh/ssh_config.
Alternative Fix: Update the Server
If you control the server, the best fix is to update its SSH configuration to use modern host keys. On most Linux servers, edit /etc/ssh/sshd_config and ensure these lines are present:
HostKey /etc/ssh/ssh_host_ed25519_keyHostKey /etc/ssh/ssh_host_rsa_key
Then restart the SSH service (e.g., sudo systemctl restart sshd). If the server is very old and does not support Ed25519, at least regenerate the RSA key with a larger size:
sudo ssh-keygen -t rsa -b 4096 -f /etc/ssh/ssh_host_rsa_key
After that, the server will offer a modern RSA key with SHA-2 signatures, which clients accept by default.
Common Mistakes and Misconceptions
One common mistake is using -oHostKeyAlgorithms=ssh-rsa without the plus sign. That replaces the entire default list, which can break other connections or make the client try only that algorithm. Always use the plus sign to append.
Another misconception is that this error is about passwords or authentication. It is not. The error occurs before any password prompt, because the client refuses to even start the key exchange. If you see this error, your credentials are irrelevant until the host key issue is resolved.
Some users confuse this with “REMOTE HOST IDENTIFICATION HAS CHANGED”. That is a different error that happens when the server’s key differs from the one stored in known_hosts. The fix for that is to remove the old key with ssh-keygen -R hostname, but only after verifying the server is not compromised.
Frequently Asked Questions
Is it safe to re-enable ssh-rsa?
It is not ideal, but it is acceptable for a temporary connection to a legacy server you trust. The risk is that an attacker could potentially forge a host key using a SHA-1 collision, but this is extremely difficult in practice. For any long-term use, update the server instead.
What does “Their offer: ssh-rsa” mean?
It means the server is telling the client which host key algorithms it supports. The client then checks its own list and finds no overlap, hence the error. The solution is to add the offered algorithm to the client’s list.
Does this error affect all SSH clients?
No. It affects clients that have disabled old algorithms by default, primarily OpenSSH 8.8 and newer. Older clients may connect without issue, but they are also more vulnerable. PuTTY and other clients have their own settings and may show a different message.
How do I permanently allow ssh-rsa for all hosts?
Add HostKeyAlgorithms +ssh-rsa to the Host * section of your ~/.ssh/config. This is not recommended because it weakens security for every server, but it will work. Better to limit it to the specific host that needs it.
Will this error go away if I update my client?
No. Newer clients are more likely to disable old algorithms, so updating may actually make the error appear if it did not before. The fix is to either update the server or explicitly allow the old algorithm on the client.
Can I use a different key type like ECDSA instead?
Yes, if the server supports it. You can generate an ECDSA host key on the server with ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key and add the corresponding HostKey line. Most modern clients support ECDSA by default, so this often resolves the issue without weakening security.
Related
Formula used
in t | Finish time | min | 50 | 0 in d | Distance | km | 10 | 0 | 100000 out pace | Average pace | min/km | t / d | 2 out speed | Average speed | km/h | d / (t / 60) | 2
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Delete Picture Kik? How to Remove Photos
- What Happens to X Replies, DMs, and Followers After Deletion?
- Data Breaches That Shook the World
- Disable Google Assistant: Turn It Off on Android & Home
- Resin vs FDM Printers for Miniatures: Detail, Durability, Cost
- Are Networked Implants Safe? What If One Fails?