Created
January 20, 2012 10:59
-
-
Save AlD/1646701 to your computer and use it in GitHub Desktop.
NeDi - remove changed hostkeys from known_hosts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
mysql nedi --column-names=false -Be ' | |
SELECT INET_NTOA(d.ip) | |
FROM messages m | |
JOIN devices d | |
ON m.source = d.name | |
WHERE m.time > UNIX_TIMESTAMP() - 86400 | |
AND m.info LIKE "%hostkey changed%"; | |
' | ( | |
while read line; do | |
echo "removing ${line}" >&2 | |
echo "/^${line} ssh-/d" | |
done | |
echo "wq" | |
) | ed -s ~/.ssh/known_hosts | |
# licensed under GPL, Daniel Albers <[email protected]>, 20120120 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment