Created
March 28, 2011 08:33
-
-
Save thwarted/890156 to your computer and use it in GitHub Desktop.
the script I use to restore my ssh-agent settings to running screen sessions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$TERM" != "screen" ]; then | |
# if the auth socket variable is empty, don't do anything | |
if [ ! -z "$SSH_AUTH_SOCK" ]; then | |
# include USER to protect against shared HOME directories (rare) | |
NEWSOCK=$HOME/.agent-sshscreen-$USER.sock | |
if [ "$SSH_AUTH_SOCK" != "$NEWSOCK" ]; then | |
# test if the auth sock we have is actually working | |
# don't link to a dead socket | |
if ssh-add -l > /dev/null 2>&1; then | |
/bin/ln -sf $SSH_AUTH_SOCK $NEWSOCK | |
export SSH_AUTH_SOCK=$NEWSOCK | |
fi | |
fi | |
fi | |
exec /usr/bin/screen "$@" | |
else | |
echo "can't start up screen inside screen" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment