How to Fix: SSH Host Key error to Managed Devices

How to Fix: SSH Host Key error to Managed Devices

How to Fix: SSH Host Key error to Managed Devices

When receiving the message "Login error: Host key for server 'DEVICE_IP' does not match" or similar when starting an SSH session to managed devices.

In case of managed devices, you'll need to change the keys on /etc/device_keys/known_hosts file.

You'll need first to go to the shell and to the folder:
shell sudo su -
cd /etc/device_keys/

Take a backup of the known_hosts file as a precaution:

cp known_hosts known_hosts.backup

And then either change the key on the file to the one expected or removing the entire line:
You can vi into it and change the key or removing the line:
vi known_hosts

Or cat the file (to get the line where the device is) and remove the specific line:
cat known_hosts
sed -i 'Nd' known_hosts

Where N is the line number of the ssh_key from the file.

After that, you'll be able to reconnect to the device with SSH.

Note: This can also affect Web connections made from Cluster peers who have incorrect SSH host keys.