SSH connection to old servers

When you are on a newer Linux distribution and try to connect to older server, you might run into a problem and get message like:

ssh [email protected]
Unable to negotiate with xxx.xx.xxx.xxx port 22: no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1

Something your SSH client and SSH daemon on the server can not agree on.

The fix.

In your user’s folder (on client machine) create file called ~/.ssh/config

Put the following settings and adjust them as necessary:

Host server-alias
  HostName full-server-name.com
  User your_username
  Port 22
  PubkeyAcceptedKeyTypes +ssh-rsa
  HostKeyAlgorithms ssh-rsa
  KexAlgorithms diffie-hellman-group1-sha1

# If you have custom SSH key, you might want to specify it too
Host *
  IdentityFile ~/Sites/privatekey.pem

Now try to simply run

ssh server-alias

Hope it helps!