Skip to content

Instantly share code, notes, and snippets.

@tobym
tobym / ssh-reagent.sh
Created September 19, 2011 20:38
Easy way to reconnect to a running ssh-agent session (better than opening a new one!)
# source: http://tychoish.com/rhizome/9-awesome-ssh-tricks/
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