Fix SSH Agent

This commit is contained in:
Max Bucknell 2016-12-29 18:39:15 +00:00
parent 21f0c5845e
commit 008c5aabe6

View file

@ -132,12 +132,20 @@ function start-agent {
ssh-add "$HOME/.ssh/id_$(nice-hostname)" ssh-add "$HOME/.ssh/id_$(nice-hostname)"
} }
# If we may have loaded config, let's just check that
function test-identities {
if ! ssh-add -l > /dev/null; then
start-agent
fi
}
# Start SSH Agent if it's not already running. # Start SSH Agent if it's not already running.
# #
# Also add the id_(nice-hostname) identity. # Also add the id_(nice-hostname) identity.
export SSH_ENV="$HOME/.ssh/environment" export SSH_ENV="$HOME/.ssh/environment"
if [[ -f $SSH_ENV ]]; then if [[ -f $SSH_ENV ]]; then
. $SSH_ENV > /dev/null . $SSH_ENV > /dev/null
test-identities
else else
start-agent start-agent
fi fi