in Uncategorized

add ssh identities to your ssh agent when you start your bash session

Put this somewhere on your .bash_profile

[bash]
function addSSHIdentities() {
pushd ~/.ssh
#add all your keys here
ssh-add some_private_key
ssh-add some_private_key_2
ssh-add some_private_key_3

ssh-add some_private_key_N
popd
}

function startSSHAgent() {
SSH_AGENT_PROCESSES=`ps aux | grep ssh-agent | grep -v grep | wc -l`

if [ $SSH_AGENT_PROCESSES -gt 0 ]
then
echo "SSH Agent was running. Not adding identities"
else
echo "Starting ssh-agent…"
ssh-agent
echo "Adding SSH Identities"
addSSHIdentities
fi
}

startSSHAgent
[/bash]

Write a Comment

Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.