Skip to content

Instantly share code, notes, and snippets.

@fourdollars
Created November 29, 2013 03:40
Show Gist options
  • Save fourdollars/7701280 to your computer and use it in GitHub Desktop.
Save fourdollars/7701280 to your computer and use it in GitHub Desktop.
A little script to launch ssh-agent automatically.
#!/bin/sh
if [ -f "$HOME/.ssh-agent" ]; then
. "$HOME/.ssh-agent"
fi
PID="$(pidof ssh-agent)"
if [ -z "$PID" -o "$PID" != "$SSH_AGENT_PID" ]; then
if [ -n "$PID" ]; then
killall ssh-agent
fi
ssh-agent | head -n 2 > "$HOME/.ssh-agent"
. "$HOME/.ssh-agent"
ssh-add
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment