Screen-ssh is a small script that loops on ssh to keep you logged into a remote host across network disconnections (and movements to different networks). State is retained on the remote host by using screen to encapsulate the session. So, the ssh just hops to the remote host and attaches to an instance of screen (unless this is the initial connection) and you keep working. This is all pretty easy, but using multiple ssh connections ends up using multiple tunnels for both X forwarding and ssh-agent forwarding. So, the mess of this process is caused by coaxing an already running shell to attach to these new tunnels.

Mark Allman -