#!/bin/sh # When SSH-ing with agent forwarding enabled, this variable is set by sshd # itself. However, an existing screen session that we attach to will not have # its SSH_AUTH_SOCK environment variable updated, so we hardcode this path in # .screenrc and create a symlink to keep it alive. # # It WILL break if two sessions are opened to a machine, and a newer one is # terminated. ControlMaster in .ssh/config solves this problem by sharing the # connection (and as a result, sharing SSH agent socket). [ -n "$SSH_AUTH_SOCK" ] && ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock