Skip to content

Instantly share code, notes, and snippets.

@taylor
Created July 15, 2014 19:51
Show Gist options
  • Select an option

  • Save taylor/dcbab4a2e12e985bb294 to your computer and use it in GitHub Desktop.

Select an option

Save taylor/dcbab4a2e12e985bb294 to your computer and use it in GitHub Desktop.
#!/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