Skip to content

Instantly share code, notes, and snippets.

@davidlee
Created February 18, 2010 00:48
Show Gist options
  • Save davidlee/307200 to your computer and use it in GitHub Desktop.
Save davidlee/307200 to your computer and use it in GitHub Desktop.
# NOTE: see http://www.dribin.org/dave/blog/archives/2007/11/28/ssh_agent_leopard/
# on leopard, DON'T run ssh-agent; just ssh-add and it will work.
export agentfile=/tmp/.ssh_agent
function start_ssh_agent() {
echo > $agentfile
chmod 600 $agentfile
ssh-agent > $agentfile
load_ssh_agent
}
function load_ssh_agent() {
source $agentfile > /dev/null
}
function load_or_start_ssh_agent() {
if [[ -f $agentfile ]]; then
load_ssh_agent
else
start_ssh_agent
fi
}
alias ssh-agent=load_or_start_ssh_agent
ssh-agent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment