SSH "Unable to negotiate": no matching host key type
This error means ssh reached an address and the two sides began talking, but the client and the server had no algorithm in common, so the session never started. It comes before any host key prompt, key offer or password, so those are not the problem yet. The usual story is a newer client meeting an older device, or a client that was tightened, but the message alone does not say which.
This page describes standard OpenSSH behaviour. The commands are the usual ones, and wording and defaults differ between versions, distributions and platforms. We did not run them against a particular server for this page, and the algorithm names below are examples, not lists of what any version offers.
What the message means
Unable to negotiate with 192.0.2.10 port 22: no matching host key type found. Their offer: ssh-rsa
The same form appears for the other things the two sides must agree on:
no matching key exchange method found,
no matching cipher found and no matching MAC found.
Each is one list that the client and the server did not share. The address and
port in the message are the machine that did not agree. When a jump host or
proxy is in use, that can be a hop on the way and not the final machine.
When it is printed, Their offer: is the list the other side sent.
Some versions leave it out. If you read an sshd log on the server instead, the
same wording usually shows the client's list there, so the direction is the
other way round.
That tells it apart from the other early errors. Could not resolve hostname means ssh never had an address. A timeout or a refused connection means no TCP connection was made. A closed or reset handshake, covered in SSH "kex_exchange_identification: Connection closed", means the other end ended the exchange, where here both sides answered and disagreed. A host key warning, such as the changed host key one or the first-connection prompt, and Permission denied (publickey) all come after a host key was chosen, so this page does not cover them.
1. Confirm it is this error and nothing earlier
Read the last lines of the output. If the words are
Unable to negotiate or no matching ... found, you
are in the right place. If you see one of the messages in the paragraph above,
use that guide first. Running again with -v shows more:
ssh -v user@server.example.com
The ssh -v output reader checks a pasted log for well-known messages, including this one, and links the matching guide. It runs in your browser and sends nothing.
Check that the address is the machine you meant, and that your config is not changing it or adding a jump host without your noticing:
ssh -G myserver | grep -i -E '^(hostname|port|proxycommand|proxyjump) '
The ssh -G output reader shows the same values from a pasted copy of the full output. It runs in your browser and sends nothing.
2. Read their offer
Look at which kind of thing did not match, and then at the names after
Their offer:. Names such as ssh-rsa or
ssh-dss for a host key, an old Diffie-Hellman group for key
exchange, or CBC and 3DES ciphers are typical of a device that has not been
updated for a long time. That is a pattern to look for, not a rule, and it
says nothing about whether a particular name is safe or retired in your
version.
If there is no Their offer: line, ssh -vv logs both
sides' proposals in many versions, in lines that start with
debug2: and name the algorithms. The wording varies, so look for
the lists and not for an exact phrase.
3. Compare it with what this client can do
OpenSSH can list the names the client you are running supports. These are
standard ssh -Q queries:
ssh -Q key
ssh -Q kex
ssh -Q cipher
ssh -Q mac
key covers the host key types, kex the key exchange
methods. These show what the program knows, which is not always what it will
use. The values your config and defaults actually select, for one host, appear
in the output of ssh -G myserver on the lines beginning
hostkeyalgorithms, kexalgorithms,
ciphers and macs.
The ssh -Q output reader lists the names in a pasted copy and checks whether one name appears in it. It runs in your browser and sends nothing.
Then compare the lists with their offer. Three outcomes are common:
-
Their offer has a name your client does not support at all.
It is not in
ssh -Qfor that kind. No setting on this client will make it match. The options are another client that still has it, or changing the server. -
Their offer has a name your client supports but is not using.
It appears in
ssh -Qbut not in thessh -Gline. Newer OpenSSH releases have dropped some older algorithms from what they use by default over time, which varies by version, so a client update can start this on a server that did not change. - The lists have names in common on paper. Then something is limiting one side more than it seems. Look at your config next, and at the server's.
4. Check whether a setting you control is the cause
A HostKeyAlgorithms, KexAlgorithms,
Ciphers or MACs line in
~/.ssh/config or in a system-wide config file replaces the
defaults for the hosts it matches. A fixed list copied from a hardening guide,
or a Host * block, can leave out what an older server needs. Some
distributions also apply a system-wide cryptographic policy. The
ssh -G lines above show the result either way.
If the server is yours, its own sshd_config can limit the same
four things, and a device with only one host key of an older type can offer
nothing newer. Reading that file needs a console, someone on site or a session
you already have open.
5. Choose the fix, in this order
- Update the server. A newer sshd, or firmware that includes one, is the fix that leaves every client able to connect with current algorithms. It may be a vendor's job or not possible for a given device.
- Use a client that supports what the server offers for that one machine, if you cannot change the server yet.
-
Re-enable one algorithm for one host, as a last resort.
OpenSSH lets you add to the list for a single connection, with a
+in front of the name:
ssh -o HostKeyAlgorithms=+ALGORITHM user@server.example.com
Replace ALGORITHM with one name taken from their offer that your
client supports. For a key exchange method, cipher or MAC the options are
KexAlgorithms, Ciphers and MACs. This
has a security cost: you are choosing to use something that was set aside for
a reason, on a link that may cross networks you do not control. Keep it narrow
and understood. Use one name, for one host, and not in a
Host * block or a global setting, and remove it when the server
is updated. Do not paste a long list of old algorithms from a forum answer.
A login step has its own algorithm limits in some versions, so a connection that now gets past this error can still end in Permission denied (publickey). That is a separate problem with its own checks. Once a host key is accepted you may also meet the first-connection prompt.
If the machine is a RescueShell device
A path that starts from the device can help when you would otherwise connect to a public SSH port. The agent on the device keeps an outbound HTTPS connection to our relay, so reaching a shell does not depend on a client and an old public sshd agreeing on algorithms. That needs the agent installed and running first.
It does not change that if you still connect straight to that public port, the old sshd and your newer client still have to agree. If a shell does not open once the agent is installed, see the shell does not open.
Try it on one device
The first device is free to try with no card, for 30 days from when it connects, not from when you sign up. Start a trial.