Created
October 13, 2016 10:03
-
-
Save jdevera/854b8fcba903919261e95312660da6bb to your computer and use it in GitHub Desktop.
Function to start an ssh agent or load a running one into the current environment
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 ssh-agent-start() | |
{ | |
local agentfile=~/.ssh/agent | |
if [[ -f $agentfile ]] | |
then | |
source $agentfile > /dev/null | |
if ps -p "$SSH_AGENT_PID" > /dev/null | |
then | |
echo "Agent running with PID $SSH_AGENT_PID" | |
return | |
fi | |
fi | |
echo "Could not find running agent. Starting new..." | |
ssh-agent > $agentfile | |
source $agentfile > /dev/null | |
echo "Agent running with PID $SSH_AGENT_PID" | |
ssh-add | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment