So this has proved to be a very difficult thing to google. I have a work setup where I run everything off of a laptop that I hibernate or shut down at the end of the day. Doing so obviously cuts off my SSH session in puTTY. After a bit of poking, I discovered a good way to auto-boot screen and pick up the disconnected session when connecting via puTTY (namely, adding if [ -z "$STY" ]; then screen -R; fi
to the end of my .bashrc).
This works wonderfully, but I still have a problem. I use SSH agent forwarding via Pageant on my laptop (where I initially enter the password) to secondary servers. From what I can tell, this socket is broken when the puTTY session breaks and does not reconnect when reloading and reconnecting to screen.
Here's my test:
20:01:38 {~/test}$ git clone [email protected]:coldcandor/env.git
Cloning into 'env'...
remote: Counting objects: 1105, done.
remote: Total 1105 (delta 0), reused 0 (delta 0), pack-reused 1105
Receiving objects: 100% (1105/1105), 341.06 KiB | 453.00 KiB/s, done.
Resolving deltas: 100% (544/544), done.
Checking connectivity... done.
20:01:43 {~/test}$ rm -rf env
Disconnect puTTY and reconnect
20:01:58 {~/test}$ git clone [email protected]:coldcandor/env.git
Cloning into 'env'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
As you can see, it doesn't preserve the forwarding. However, if I either do not reconnect to screen, or fully exit and reopen screen after reconnecting, then it's fine.
How do I get around this?