Fixing "'no matching key exchange method found. Their offer: diffie-hellman-group1-sha1" on Mac


This is going to be a lovely short post.

Here's the issue:

dchidell@dchidell-mac:~$ ssh [email protected]
Unable to negotiate with port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1


Ideally we'd fix the server so that is supports a secure key exchange mechanism. Often that's not possible, and from a test perspective it's far easier to workaround the issue on the client.

So, from a client perspective you can do this:

dchidell@dchidell-mac:~$ echo -e 'Host *.*.*.*\n\tKexAlgorithms +diffie-hellman-group1-sha1' >> ~/.ssh/config
dchidell@dchidell-mac:~$ cat ~/.ssh/config
Host *.*.*.*
   KexAlgorithms +diffie-hellman-group1-sha1
dchidell@dchidell-mac:~$ ssh [email protected]
Warning: Permanently added '' (RSA) to the list of known hosts.
[email protected]'s password: 


Here's the line again:

echo -e 'Host *.*.*.*\n\tKexAlgorithms +diffie-hellman-group1-sha1' >> ~/.ssh/config

I have seen some situations where a single wildcard works where 4 does not, in the event that the above does not work, try the following:

echo -e 'Host *\n\tKexAlgorithms +diffie-hellman-group1-sha1' >> ~/.ssh/config