[[screen]] or `startx`) to that new terminals come up knowing about
the agent.
+Grabbing a ssh-agent by process ID
+----------------------------------
+
+If you clobber your `ssh-agent` environment somehow (or you want to
+“borrow” another user's agent to show them the security risks of
+running an agent on a computer that they don't own),
+[[ssh-agent-grab.sh]] will show you how to setup your environment:
+
+ $ ps -ef ssh-agent
+ ...
+ jdoe 11862 1 0 Nov18 ? 00:00:01 ssh-agent
+ ...
+ $ ssh-agent-grab.sh 4580
+ export SSH_AUTH_SOCK=/tmp/ssh-oTZLe11861/agent.11861
+ export SSH_AGENT_PID=11862
+ $ export SSH_AUTH_SOCK=/tmp/ssh-oTZLe11861/agent.11861
+ $ export SSH_AGENT_PID=11862
+ $ ssh jdoe@elsewhere
+
+
Credits
-------
--- /dev/null
+#!/bin/bash
+
+if [ "$#" -ne 1 ]; then
+ echo 'usage: ssh-grab-agent.sh PID'
+ exit 1
+fi
+
+PID=$1
+
+export SSH_AUTH_SOCK=$(/bin/ls /tmp/ssh-*/agent.$PID 2>/dev/null)
+if [ -z "$SSH_AUTH_SOCK" ] ; then
+ let "PID2 = PID-1"
+ export SSH_AUTH_SOCK=$(/bin/ls /tmp/ssh-*/agent.$PID2)
+fi
+echo "export SSH_AUTH_SOCK=$SSH_AUTH_SOCK"
+echo "export SSH_AGENT_PID=$PID"
+
+exit 0