The Problem
I use Screen to leave programs running and an SSH key agent to shell between machines and use CVS without reentering my password. Disconnnecting from the server that the screen session is running on removes the connection to the SSH agent.
What should happen:
latestssh, to reattach my current SSH agent to the screen window
The Solution
A shell snippet (Zsh, but easily portable):
local agentdir=~/.latestssh
local agentfile=$agentdir/$HOST.sh
mkdir -p $agentdir
chmod 0700 $agentdir >/dev/null
if [ -n "$SSH_AUTH_SOCK" -a -z $STY ]; then
echo "export SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >$agentfile
chmod 0600 $agentfile >/dev/null
fi
#...existing windows can run this alias
alias latestssh="source $agentfile; ls \$SSH_AUTH_SOCK"
#...new windows get it automatically
if [ -n "$STY" ]; then
source $agentfile
fi
ooh that annoys me... (Score:1)
Have I mentioned that you rock? heh
Re:ooh that annoys me... (Score:1)
If you're wondering how to set up an SSH key agent, there are lots of tutorials out there. I use the widely-distributed "keychain" utility as well.
qw(Ian Langworth)