Last active
August 12, 2019 01:58
-
-
Save cmer/ae91fc7e97ad3e7933df9ff56a08563b to your computer and use it in GitHub Desktop.
Script to remove last attempted SSH host from ~/.ssh/known_hosts
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
#!/usr/bin/env ruby | |
host = ARGV[0].to_s | |
if host == "" | |
history_output = `cat ~/.bash_history | grep "^ssh\s" | tail -1` | |
host = history_output.sub(/^ssh\s/i, '').split("@").last.split(" ").first | |
end | |
puts `ssh-keygen -R #{host}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment