Created
May 15, 2014 16:06
-
-
Save thecubic/c17140d62f1ddf8b010a to your computer and use it in GitHub Desktop.
deletes specific line(s) 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/bash | |
# Problem: | |
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | |
# @ 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 a host key has just been changed. | |
# The fingerprint for the RSA key sent by the remote host is | |
# ce:ed:2d:9a:9b:90:50:74:f5:48:88:56:10:c1:dd:d4. | |
# Please contact your system administrator. | |
# Add correct host key in /home/thecubic/.ssh/known_hosts to get rid of this message. | |
# Offending RSA key in /home/thecubic/.ssh/known_hosts:889 | |
# Password authentication is disabled to avoid man-in-the-middle attacks. | |
# Keyboard-interactive authentication is disabled to avoid man-in-the-middle attacks. | |
# X11 forwarding is disabled to avoid man-in-the-middle attacks. | |
# Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). | |
# Warning: Permanently added 'gibson' (RSA) to the list of known hosts. | |
# Warning: the RSA host key for 'gibson' differs from the key for the IP address '10.216.17.99' | |
# Offending key for IP in /home/thecubic/.ssh/known_hosts:884 | |
# Solution: | |
# khdel 884 889 | |
for i in $(for i in "$@"; do echo $i; done | sort -rn | uniq); do echo ${i}d ; done | sed -i.bak -f - ~/.ssh/known_hosts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment