Skip to content

Instantly share code, notes, and snippets.

@stephanschubert
Created September 19, 2011 11:45
Show Gist options
  • Save stephanschubert/1226348 to your computer and use it in GitHub Desktop.
Save stephanschubert/1226348 to your computer and use it in GitHub Desktop.
Stick this in your shell configuration (e.g. ~/.bashrc or ~/.zshrc) and run ssh-reagent whenever you have an agent session running and a terminal that can't see it.
ssh-reagent () {
for agent in /tmp/ssh-*/agent.*; do
export SSH_AUTH_SOCK=$agent
if ssh-add -l 2>&1 > /dev/null; then
echo Found working SSH Agent:
ssh-add -l
return
fi
done
echo Cannot find ssh agent - maybe you should reconnect and forward it?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment