Created
May 1, 2015 13:43
-
-
Save apenney/992977b996b84dc26edc to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# http://techblog.appnexus.com/2011/managing-ssh-sockets-in-gnu-screen/ | |
# https://gist.github.com/martijnvermaat/8070533 | |
# http://stackoverflow.com/questions/21378569/how-to-auto-update-ssh-agent-environment-variables-when-attaching-to-existing-tm | |
# Fix SSH auth socket location so agent forwarding works with screen. | |
if test "$SSH_AUTH_SOCK" ; then | |
ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock.$(hostname) | |
fi | |
# Don't break x11 Forwarding: | |
# Taken from the sshd(8) manpage. | |
if read proto cookie && [ -n "$DISPLAY" ]; then | |
if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then | |
# X11UseLocalhost=yes | |
echo add unix:`echo $DISPLAY | | |
cut -c11-` $proto $cookie | |
else | |
# X11UseLocalhost=no | |
echo add $DISPLAY $proto $cookie | |
fi | xauth -q - | |
fi | |
### | |
tmux.conf | |
# fix ssh agent when tmux is detached | |
set -g update-environment -r | |
setenv -g SSH_AUTH_SOCK $HOME/.ssh/ssh_auth_sock.$HOSTNAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment