Created
March 11, 2014 07:07
-
-
Save teerapap/9480910 to your computer and use it in GitHub Desktop.
bashrc to initialize ssh-agent daemon(if not running) on ssh-login
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
####SSH-agent setting#### | |
AGENT_INFO="$HOME/.ssh/agent.info" | |
function start_agent { | |
echo "Initializing new SSH agent..." | |
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${AGENT_INFO}" | |
chmod 600 "${AGENT_INFO}" | |
. "${AGENT_INFO}" > /dev/null | |
} | |
# Source SSH settings, if applicable | |
if [ -f "${AGENT_INFO}" ]; then | |
. "${AGENT_INFO}" > /dev/null | |
ps -p ${SSH_AGENT_PID} > /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