From: Colin Patrick Mccabe Date: Wed, 4 Jun 2014 22:17:43 +0000 (-0700) Subject: add ssh-restore.sh X-Git-Url: http://www.club.cc.cmu.edu/~cmccabe/cgi-bin/gitweb.cgi?p=cmccabe-bin;a=commitdiff_plain;h=d67fc462b361dd2098f829977bc842a1b7ab5b41 add ssh-restore.sh Signed-off-by: Colin McCabe --- 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