Reactivate old SSH host key types

Problem: ssh rejects connecting to old servers with this error:

# ssh SRV
Unable to negotiate with SRV port 22: no matching host key type found. Their offer: ssh-rsa
or
Unable to negotiate with SRV port 22: no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1

Discussion: After upgrading your client operating system, the new installed openssh-client disabled some old ssh key type and key exchange mechanisms, but you can enable them with command line options or in ssh_config.

Solution 1: Add a command line option:

# ssh -oHostKeyAlgorithms=+ssh-rsa -oKeyAlgorithms=+diffie-hellman-group-exchange-sha1 SRV

Solution 2: Add a line to your config file /etc/ssh/ssh_config

Host *
   HostKeyAlgorithms=+ssh-rsa
   KexAlgorithms=+diffie-hellman-group-exchange-sha1

You can add a “Host” section for the specific host that needs old ssh key types.