Created
July 13, 2009 16:56
-
-
Save mboeh/146256 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
capture () { | |
echo $SSH_AUTH_SOCK > /tmp/$(whoami)-auth-sock-path | |
} | |
clean () { | |
rm /tmp/$(whoami)-auth-sock-path | |
} | |
apply () { | |
mkdir -p $(dirname $SSH_AUTH_SOCK) | |
ln -sf $(cat /tmp/$(whoami)-auth-sock-path) $SSH_AUTH_SOCK | |
clean | |
} | |
$1 |
This file contains hidden or 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
SSH Agent Forwarding Abusive Trickery | |
Useful in screen sessions when your SSH connection is lost. When you connect again, you end up with a new SSH agent socket ($SSH_AUTH_SOCK), but when you reconnect to screen, the value of $SSH_AUTH_SOCK will remain unchanged and your agent forwarding will be broken. | |
# The proper, somewhat irritating solution | |
1. `echo $SSH_AUTH_SOCK' OUTSIDE screen and copy its result | |
2. Attach to your screen session and hit Ctrl-A+:. Type `setenv SSH_AUTH_SOCK $(value of SSH_AUTH_SOCK from outside)` | |
3. Either close and reopen every window in screen or execute `export SSH_AUTH_SOCK=$(value of SSH_AUTH_SOCK from outside)' or similar in every terminal you'll be using SSH in. Note: this sucks. | |
# The cheap, lazy solution | |
1. `echo $SSH_AUTH_SOCK > /tmp/$(whoami)-auth-sock-path` outside screen | |
2. Inside screen, open a terminal. `mkdir $(dirname $SSH_AUTH_SOCK); ln -sf $(cat /tmp/$(whoami)-auth-sock-path) $SSH_AUTH_SOCK; rm /tmp/$(whoami)-auth-sock-path` | |
# The incredibly lazy solution | |
Grab the screen-agent-fix script attached, put it in your $PATH, and run it like this: | |
1. `screen-agent-fix.sh capture' OUTSIDE | |
2. `screen-agent-fix.sh apply' INSIDE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment