Skip to content

Instantly share code, notes, and snippets.

@viktorbenei
Created November 7, 2014 13:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save viktorbenei/ae99d688674b517d0434 to your computer and use it in GitHub Desktop.
Save viktorbenei/ae99d688674b517d0434 to your computer and use it in GitHub Desktop.
kill ssh agent and load a new one
#!/bin/bash
echo "----------------"
echo "Removing existing keys"
ssh-add -K
echo "----------------"
echo "List of keys:"
ssh-add -l
echo "----------------"
ssh-agent -k
eval $(ssh-agent)
echo >> ~/.bashrc
echo "export SSH_AUTH_SOCK=${SSH_AUTH_SOCK}" >> ~/.bashrc
echo "----------------"
exit 0
@killrazor
Copy link

ssh-add -K is not an option for BSD.

https://help.github.com/articles/error-ssh-add-illegal-option-k/

Also, anyone reading this might want to review http://rabexc.org/posts/pitfalls-of-ssh-agents for a better way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment