Skip to content

Instantly share code, notes, and snippets.

@Lunik
Created October 25, 2019 07:12
Show Gist options
  • Save Lunik/43a09b1b46a8c2552bf1b962d7d473a8 to your computer and use it in GitHub Desktop.
Save Lunik/43a09b1b46a8c2552bf1b962d7d473a8 to your computer and use it in GitHub Desktop.
# SSH
SSH_AGENT_CONFIG="$HOME/.ssh-agent"
function start_ssh_agent() {
echo "[SSH] Starting agent"
ssh-agent > "${SSH_AGENT_CONFIG}"
source "${SSH_AGENT_CONFIG}" 2>&1 >/dev/null
}
if [ -f "${SSH_AGENT_CONFIG}" ]; then
source "${SSH_AGENT_CONFIG}" 2>&1 >/dev/null
ping_process=$(kill -0 "${SSH_AGENT_PID}" 2>&1 >/dev/null)
if [ "$?" -ne "0" ]; then
start_ssh_agent
fi
else
start_ssh_agent
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment