Created
April 29, 2012 07:10
-
-
Save janosgyerik/06217445c76729e05297 to your computer and use it in GitHub Desktop.
Setup ssh agent automatically on login
This file contains 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 setup | |
SSH_ENV=$HOME/.ssh/env | |
start_ssh_agent() { | |
ssh-agent > $SSH_ENV | |
. $SSH_ENV | |
} | |
check_ssh_agent() { | |
. $SSH_ENV && test "$SSH_AGENT_PID" && ps -p $SSH_AGENT_PID >/dev/null | |
} | |
check_ssh_identity() { | |
ssh-add -L >/dev/null | |
} | |
add_ssh_identity() { | |
ssh-add | |
} | |
ssh_agent_setup() { | |
check_ssh_agent || start_ssh_agent && check_ssh_identity || add_ssh_identity | |
} | |
ssh_agent_setup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment