Created
October 4, 2011 20:48
-
-
Save timkuijsten/1262755 to your computer and use it in GitHub Desktop.
load a private key for 24 hours in the ssh-agent
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
# if we have private keys, load ssh-agent or connect to an already running agent | |
if [ -r $HOME/.ssh/id_rsa -o -r $HOME/.ssh/id_dsa -o -r $HOME/.ssh/identity ]; then | |
SSH_SOCKET=$HOME/.ssh/.ssh-socket | |
# ensure socket | |
ps -cx | grep -q '[s]sh-agent' | |
if [ 0 -ne $? ]; then | |
old_umask=$(umask) | |
umask 0077 | |
ssh-agent -t 86400 > $SSH_SOCKET | |
umask $old_umask | |
fi | |
# if $SSH_SOCKET exists, is readable and is not empty, then add my key | |
if [ -r $SSH_SOCKET -a -s $SSH_SOCKET ]; then | |
. $SSH_SOCKET | |
ssh-add -l | grep -qi 'no ident' && ssh-add -t 86400 | |
else | |
echo "Socket not readable" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment