Normally Shane Meyers clues me into nifty tricks about SSH, but this one I found on my own.  Fortunately I searched for an existing solution before coding it myself.  The new love of my SSH life is ssh-agent-proxy.  It solves the problem of ensuring the SSH_AUTH_SOCK environment variable in your remote screen sessions is connected to the agent on your connecting machine (i.e. laptop.)  I’ve seen many hacks for making this connection, usually fragments spit out at login that have to be executed in each child shell.  ssh-agent-proxy solves this problem seamlessly.

When run ssh-agent-proxy daemonizes and creates a listening socket at a well known location (default: /tmp/sshUID/agent.sock).  When it receives a connection on that socket it connects it to the upstream SSH agent.  It does this by checking all files in /tmp for the correct, live socket for a currently connected SSH connection and proxies all communication.  It also reaps dead socket files for the user in /tmp.

This means I can re-connect to a host, run screen -r and all SSH agent requests from all of my existing shells are connected to my current SSH session.  I downloaded the ssh-agent-proxy tarball, reviewed the code, and executed it two months ago; I’ve nearly forgotten it is running and am enjoying my pain-free ssh-agent-proxy life.