Created
December 6, 2015 05:41
-
-
Save outsinre/66d9ef05d8cfb241c637 to your computer and use it in GitHub Desktop.
workspace/test.txt
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
create_an_agent_socket() { | |
echo "No agents found" | |
read -p "Create an agent and add keys (y/n)?" -n 1 -r | |
echo # (optional) move to a new line | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
if [ -z "$SSH_AUTH_SOCK" -a -z "$SSH_AGENT_PID" ]; then | |
eval "$(ssh-agent -s)" > /dev/null | |
fi | |
else | |
echo "Exit without creating" | |
return 1 | |
fi | |
} | |
find_all_agent_sockets() { | |
_LIVE_AGENT_LIST= | |
find_all_ssh_agent_sockets | |
find_all_gpg_agent_sockets | |
find_all_gnome_keyring_agent_sockets | |
find_all_osx_keychain_agent_sockets | |
find_live_ssh_agents | |
find_live_gpg_agents | |
find_live_gnome_keyring_agents | |
find_live_osx_keychain_agents | |
_debug_print "$_LIVE_AGENT_LIST" | |
_LIVE_AGENT_LIST=$(echo $_LIVE_AGENT_LIST | tr ' ' '\n' | sort -n -t: -k 2 -k 1) | |
if [ -z "$_LIVE_AGENT_LIST" ]; then | |
create_an_agent_socket | |
fi | |
print_all_agent_sockets | |
if [ "$1" = "-i" ]; then | |
check_ssh_add | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment