diff options
Diffstat (limited to '')
-rw-r--r-- | bashrc/common/ssh-agent-forwarding.sh | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/bashrc/common/ssh-agent-forwarding.sh b/bashrc/common/ssh-agent-forwarding.sh index 14a880f..fb17146 100644 --- a/bashrc/common/ssh-agent-forwarding.sh +++ b/bashrc/common/ssh-agent-forwarding.sh @@ -3,12 +3,12 @@ wipe_removed_sockets() { # cleanup old agent-sockets if [ -r "${HOME}/.ssh-agent-forwarding" ]; then - cut -d" " -f2 "${HOME}/.ssh-agent-forwarding" | \ - xargs ls -a 2>/dev/null | \ - grep -f - "${HOME}/.ssh-agent-forwarding" | \ - sort -n > "${TMPFILE}" + cut -d" " -f2 "${HOME}/.ssh-agent-forwarding" | \ + xargs ls -a 2>/dev/null | \ + grep -f - "${HOME}/.ssh-agent-forwarding" | \ + sort -n > "${TMPFILE}" - mv "${TMPFILE}" "${HOME}/.ssh-agent-forwarding" + mv "${TMPFILE}" "${HOME}/.ssh-agent-forwarding" fi } @@ -47,5 +47,10 @@ if [ -n "$SSH_AUTH_SOCK" -a -n "$SSH_CLIENT" ]; then fi fi -SSH_AUTH_SOCK="${HOME}/.ssh-agent-forwarded-sock" +# if ssh auth sock not exists and the symlink exists +# change $SSH_AUTH_SOCK to the symlink +if [ ! -e "$SSH_AUTH_SOCK" -a -e "${HOME}/.ssh-agent-forwarded-sock" ]; then + SSH_AUTH_SOCK="${HOME}/.ssh-agent-forwarded-sock" +fi + export SSH_AUTH_SOCK |