Created
January 19, 2020 11:16
-
-
Save farrokhi/c5fb999918ea79d8912e7967e53702e8 to your computer and use it in GitHub Desktop.
Ensure ssh-agent is running and you have proper env variables set (re-use if possible)
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
AGENT_SCRIPT=${HOME}/load-agent.sh | |
while true; do | |
[ -r ${AGENT_SCRIPT} ] && source ${AGENT_SCRIPT} | |
if [ -n "$SSH_AGENT_PID" ]; then | |
# ensure the variable actually reflects a running ssh-agent process | |
ps -p $SSH_AGENT_PID | grep -q ssh-agent$ && break | |
fi | |
# SSH_AGENT_PID is either not set or has stale PID | |
echo "Running ssh-agent" | |
ssh-agent > ${AGENT_SCRIPT} | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment