Created
July 15, 2014 19:51
-
-
Save taylor/dcbab4a2e12e985bb294 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| function usage() { | |
| echo "usage: $0 <line number|IP>" | |
| } | |
| if [ -z "$1" ] ; then | |
| usage | |
| exit | |
| elif [ "$1" = "-y" ] ; then | |
| FORCE=1 | |
| shift | |
| fi | |
| IP=$(echo $1 |grep -E "[0-9]*\.[0-9]*\.") | |
| LINENU=$(echo $1 |grep -E "^[0-9]*$") | |
| if [ -n "$IP" ] ; then | |
| ipmsg="with ip" | |
| elif [ -z "$LINENU" ] ; then | |
| usage | |
| exit | |
| fi | |
| if [ ! "$FORCE" = "1" ] ; then | |
| echo "Press ENTER to remove line $ipmsg $1 or CTRL-C to exit" | |
| read foo | |
| fi | |
| if [ -n "$IP" ] ; then | |
| ssh-keygen -R $IP | |
| else | |
| sed -i "${LINENU}d" $HOME/.ssh/known_hosts | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment