139 Words

Introduction

I got this error message when I tried to log in to my Cisco switch with SSH.

Cisco: SSH fails to connect

Unable to negotiate with [hostname or ip] port 22: no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1,diffie-hellman-group14-sha1

You can solve this by explicitly allowing the old key exchange method:

ssh -o KexAlgorithms=+diffie-hellman-group1-sha1 [hostname or ip]

⚠️ These SHA-1 algorithms are outdated and insecure. Only use them for old network equipment, ideally on a management network.

Old host keys and ciphers

Very old switches often also need the old ssh-rsa host key, and sometimes an old cipher. Instead of typing the options every time, put them in ~/.ssh/config for just that switch:

Host oldswitch
     Hostname 192.0.2.1
     KexAlgorithms +diffie-hellman-group1-sha1,diffie-hellman-group14-sha1
     HostKeyAlgorithms +ssh-rsa
     PubkeyAcceptedAlgorithms +ssh-rsa
     Ciphers +aes128-cbc

Now ssh oldswitch works, and all other hosts keep the safe defaults.