Home > Sysadminery > SSH and Screen

SSH and Screen

November 16, 2005

I nabbed this from off google to solve the same problem. You are using screen and you disconnect and come back later and all your ssh auth sessions are broken. I modified it a bit to be friendlier about locations.

if [ ! -z "$SSH_AUTH_SOCK" ]; then
    screen_ssh_agent=/var/tmp/${LOGNAME}/state/ssh-agent-screen
    if [ "$TERM" = "screen" ]; then
        SSH_AUTH_SOCK=${screen_ssh_agent}; export SSH_AUTH_SOCK
    else
        if [ ! -d "$(dirname ${screen_ssh_agent})" ]; then
            mkdir -p $(dirname ${screen_ssh_agent})
        fi
        ln -snf ${SSH_AUTH_SOCK} ${screen_ssh_agent}
    fi
fi

Enjoy…

Advertisements
Categories: Sysadminery
%d bloggers like this: