Last active
September 17, 2024 08:21
-
-
Save cristovaov/120abe29fd2aee2ba6b2f71eefbec594 to your computer and use it in GitHub Desktop.
Launch ssh agent on bash startup on Windows for CMDR/Git Bash
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
# Start the ssh-agent | |
SSH_ENV=${HOME}/.ssh/agent.env | |
function start_agent { | |
echo "Initializing new SSH agent..." | |
# Spawning the ssh-agent | |
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}" | |
echo "Succeeded" | |
chmod 600 "${SSH_ENV}" | |
. "${SSH_ENV}" > /dev/null | |
/usr/bin/ssh-add | |
} | |
if [ -f "${SSH_ENV}" ]; then | |
. "${SSH_ENV}" > /dev/null | |
kill -0 "${SSH_AGENT_PID}" 2>/dev/null || { | |
start_agent; | |
} | |
else | |
start_agent; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment