Hello, friends. Working with SSH is essential as a sysadmin. That’s why some errors can give you many headaches, but eventually, they have a pretty simple solution. Today, for example, you will learn how to fix “host key has just been changed” error on SSH.
Although this error can give you many headaches, it is a common error that occurs when there is a change in the host RSA key. Now, this usually occurs in operating system re-installations and a change in the server’s fingerprint happens.
The error or warning message appears to avoid possible impersonation on the server. This practice can be premeditated by many sysadmins that periodically change the identity of the server to verify that the connection is valid.
But the point is that we have to fix this error. Let’s go for it.
Fix “host key has just been changed” error on SSH
When you try to access your server via ssh with this syntax, for instance
And you get this error
It is because something has changed on the server and to avoid security leaks, access to the server is denied. This, although annoying, is an important security measure for you.
To simply fix the problem of being denied ssh access, what you need to do is to delete the previous keys you had in your known hosts file
Doing this manually by editing the file can be a bit cumbersome. So, the best way to do this is to simply run
ssh-keygen -R [ip-server]
ssh-keygen -R 10.11.12.13
This will delete the key, and you will be able to access the server again.
And the issue is solved without any problems.
Finally, if the connection is made through a defined port besides 22, you can specify it with
: to be more specific.
ssh-keygen -R 10.11.12.13:[port]
In this post, you can quickly fix one of the most common errors in working with SSH.