Skip to content

Instantly share code, notes, and snippets.

@facundobianco
Last active August 29, 2015 14:20
Show Gist options
  • Save facundobianco/3f91b9e9597fdd1064d8 to your computer and use it in GitHub Desktop.
Save facundobianco/3f91b9e9597fdd1064d8 to your computer and use it in GitHub Desktop.
ssh()
{
if [ -z "$SSH_AUTH_SOCK" ]
then
eval `/usr/bin/ssh-agent`
elif [ "$SSH_AUTH_SOCK" != "`echo /tmp/ssh-*/agent.*`" ]
then
export SSH_AUTH_SOCK=`echo /tmp/ssh-*/agent.*`
fi
if [ `ssh-add -l > /dev/null 2>&1 ; echo $?` -eq 1 ]
then
echo "ssh-agent has no identities"
ssh-add -t 12h ${SSH_PRVKEY} && echo ""
fi
if [ "$?" -eq 0 ]
then
/usr/bin/ssh ${@}
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment