Created
February 7, 2015 00:00
-
-
Save tomquisel/303fc37d0e854d59b672 to your computer and use it in GitHub Desktop.
find ssh agent socket
This file contains 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
function findagent { | |
if ssh-add -l; then | |
echo "Your SSH Agent is already working." | |
return 0 | |
fi | |
for sock in `ls /tmp/ssh-*/agent.*`; do | |
export SSH_AUTH_SOCK=$sock | |
if ssh-add -l; then | |
echo "Your SSH Agent is fixed. New socket=$sock." | |
return 0 | |
fi | |
done | |
echo "Could not find any working SSH Agent sockets." | |
return 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like this approach, very functional. I added some more checks to my own version: