From d67fc462b361dd2098f829977bc842a1b7ab5b41 Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Wed, 4 Jun 2014 15:17:43 -0700 Subject: [PATCH] add ssh-restore.sh Signed-off-by: Colin McCabe --- ssh-restore.sh | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) create mode 100755 ssh-restore.sh diff --git a/ssh-restore.sh b/ssh-restore.sh new file mode 100755 index 0000000..1f64256 --- /dev/null +++ b/ssh-restore.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# +# Update the value of the ~/.ssh/ssh_auth_sock symlink to point to the new +# active socket. +# +# I like to use ssh-agent forwarding plus tmux. In practice, this means that +# the first time I start tmux, it automatically knows how to talk to my +# currently active agent. But then, when I detach tmux and log out of ssh, +# that agent goes away. On my next ssh login, I need to tell tmux about the +# new agent by updating this symlink. This script does that. +# + +if [ -S "$SSH_AUTH_SOCK" ] && [ ! -h "$SSH_AUTH_SOCK" ]; then + ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock +fi +export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock -- 1.6.6.rc1.39.g9a42