One of my Debian machines (all using some more-or-less recent version of OpenSSH) has got some fingerprints of remote machines in the known_hosts file. From time to time this remote machines get reinstalled and so they get a new fingerprint. When I now try to connect, I get the famous 'remote host identification has changed' error message instead of a working connection.
I already have a small script which can repair this situation. But my problem is to detect it automatically in a scripted way.
What I want to implement now is some other script, running in background at some time, which detects if a 'remote host identification has changed' situation occurred. If so, it should start my repair-script.
I already have some ideas for dirty hacks. Maybe I can parse the output for the error message. Or maybe I can try with and without host verification and trigger the event if only the latter one succeeds. But I wonder if there is a more clean way to detect that in an automated way.
Does anybody have an idea for that? Entirely turning off the host verification is not a working alternative of course. It might be that I don't see the wood for the trees currently...