summaryrefslogtreecommitdiffstats
path: root/bashrc
diff options
context:
space:
mode:
Diffstat (limited to 'bashrc')
-rw-r--r--bashrc/common/ssh-agent-forwarding.sh14
1 files changed, 12 insertions, 2 deletions
diff --git a/bashrc/common/ssh-agent-forwarding.sh b/bashrc/common/ssh-agent-forwarding.sh
index b18ef75..e4435ee 100644
--- a/bashrc/common/ssh-agent-forwarding.sh
+++ b/bashrc/common/ssh-agent-forwarding.sh
@@ -15,8 +15,18 @@ if [ -n "$SSH_AUTH_SOCK" -a -n "$SSH_CLIENT" ]; then
# add current socket
echo "$(date +%s) $SSH_AUTH_SOCK $SSH_CLIENT" >> "${HOME}/.ssh-agent-forwarding"
- ln -sf "$SSH_AUTH_SOCK" "${HOME}/.ssh-agent-forwarded-sock"
-
+
+ # remove old symlink
+ if [[ -L "${HOME}/.ssh-agent-forwarded-sock" ]]; then
+ rm -f "${HOME}/.ssh-agent-forwarded-sock"
+ fi
+
+ # create static symlink to socket
+ if [[ ! -e "${HOME}/.ssh-agent-forwarded-sock" ]]; then
+ ln -sf "$SSH_AUTH_SOCK" "${HOME}/.ssh-agent-forwarded-sock"
+ else
+ echo "Warning: ${HOME}/.ssh-agent-forwarded-sock exists and is not a symlink!"
+ fi
fi
SSH_AUTH_SOCK="${HOME}/.ssh-agent-forwarded-sock"