Skip to content

Instantly share code, notes, and snippets.

@fluxrad
Created September 9, 2013 19:02
Show Gist options
  • Save fluxrad/6500002 to your computer and use it in GitHub Desktop.
Save fluxrad/6500002 to your computer and use it in GitHub Desktop.
A function definition to quickly remove host+key entries from .ssh/known_hosts. Useful for when a node is replaced, or you otherwise need to remove a group of hosts.
# Remove any entries from SSH known_hosts file
# that match the specified string.
sshrm () {
node=$1
echo "Removing $node from SSH known hosts"
sed -i '.bak' -e "/^$node/d" ~/.ssh/known_hosts
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment