SSH warnings und die known_hosts

Manchmal kommt es vor das meine einen Server die IP ändert, das System neu aufsetzt bzw. den SSH key erneuert. Wenn unter dem Namen oder der IP bereits ein andere Rechner in der known_hosts eingetragen war, warnt SSH standardmäßig davor vor dem Login um auf MITM attacken abzuwehren.

ssh 192.168.0.22
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: POSSIBLE DNS SPOOFING DETECTED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The RSA host key for blog.chr.istoph.de has changed,
and the key for the corresponding IP address 192.168.0.22
is unchanged. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
Offending key for IP in /root/.ssh/known_hosts:111
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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
1e:14:52:64:3a:55:a2:02:00:00:00:22:00:84:d4:25.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:94
RSA host key for blog.chr.istoph.de has changed and you have requested strict checking.
Host key verification failed.

Blöd ist das natürlich wenn man nur eine Rescue CD eingelegt hat und den Rechner warten will. Dabei hilft es die SSH known_hosts Datei nach /dev/null zu Mappen um
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no 192.168.0.22

Wenn im einem localen netz die Server immer wieder neue DHCP Adressen bekommen, kann es hilfreich sein die internen Adressen ganz von der prüfung durch die known_hosts Datei auszuschließen. Dafür fügt man in der ~/.ssh/config Datei folgende Zeilen exemplarisch an:
Host 192.168.0.* 192.168.122.*
User root
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null

Tags: