Created
January 20, 2011 10:43
-
-
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)
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
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