Last active
August 29, 2015 14:14
-
-
Save vrivellino/c6643d9fbeb450c12187 to your computer and use it in GitHub Desktop.
Persistent ssh-agent on remove box
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
# setup ssh-agent | |
agent_env_file=~/.ssh/agent.env | |
agent_sock=~/.ssh/agent.sock | |
if [ -f $agent_env_file ] ; then | |
. $agent_env_file > /dev/null | |
if ! kill -0 $SSH_AGENT_PID > /dev/null 2>&1; then | |
echo "Stale agent file found. Spawning new agent ..." | |
eval `ssh-agent -t 4h -a $agent_sock | tee $agent_env_file` | |
ssh-add | |
fi | |
else | |
echo "Starting ssh-agent ..." | |
eval `ssh-agent -t 4h -a $agent_sock | tee $agent_env_file` | |
ssh-add | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment