Skip to content

Instantly share code, notes, and snippets.

@AlD
Created January 20, 2012 10:59
Show Gist options
  • Save AlD/1646701 to your computer and use it in GitHub Desktop.
Save AlD/1646701 to your computer and use it in GitHub Desktop.
NeDi - remove changed hostkeys from known_hosts
#!/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