Borrar una linea en el fichero known_hosts

Si has reinstalado el sistema operativo en un servidor, o le has cambiado la ip, seguramente cuando vuelvas a intentar acceder a la máquina por ssh te impedirá el acceso y recibiras un mensaje como este:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
b1:3b:85:a5:b3:ac:32:a9:6e:2e:98:7a:d5:9d:28:13.
Please contact your system administrator.
Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
Offending key in /home/user/.ssh/known_hosts:240
RSA host key for 22.33.11.44 has changed and you have requested strict checking.
Host key verification failed.
La solución es eliminar la linea número 240 del fichero known_hosts, puedes hacerlo con un editor de texto, pero es mas cómodo teclear lo siguiente:
$ ssh-keygen -R hostname|ip
Copypasteado sin malicia de Robot plays Guitar, gran tip que desconocía y evitará que abra el editor en estas situaciones.

About the author

Óscar
has doubledaddy super powers, father of Hugo and Nico, husband of Marta, *nix user, Djangonaut and open source passionate.