Skip to content

Instantly share code, notes, and snippets.

@wjlroe
Created January 20, 2011 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wjlroe/787718 to your computer and use it in GitHub Desktop.
Save wjlroe/787718 to your computer and use it in GitHub Desktop.
Function to help set the ssh auth sock (helps with screen/tmux usage)
function set_current_ssh_auth_sock {
current_ssh_auth_sock=${1:-~/.ssh/current_ssh_auth_sock}
if [ ! -e "$current_ssh_auth_sock" -o -h "$current_ssh_auth_sock" ]
then
if file -L "$current_ssh_auth_sock" >/dev/null
then
SSH_AUTH_SOCK="$current_ssh_auth_sock"
else
rm -f "$current_ssh_auth_sock"
ln -s $SSH_AUTH_SOCK "$current_ssh_auth_sock"
SSH_AUTH_SOCK="$current_ssh_auth_sock"
fi
else
echo "error: $current_ssh_auth_sock is not a symlink"
fi
}
current_ssh_auth_sock=~/.ssh/current_ssh_auth_sock
if [[ -n "$SSH_AUTH_SOCK" ]] \
&& [[ "$SSH_AUTH_SOCK" != "$current_ssh_auth_sock" ]] \
&& ! echo "$SSH_CLIENT" | fgrep '192.168' -q
then
set_current_ssh_auth_sock "$current_ssh_auth_sock"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment