Years ago when I first stared listening to podcasts when I had barely worked at PRWeb for a year even, I came up with a piece of shell script to automatically start up an ssh-agent and ask for your passphrase.
Unfortunately, the code created tons of ssh-agents, which was unfortunate.
Here is a version that behaves much better:
2 export SSH_RECENT="$HOME/.ssh/recent"
3 [ -f $SSH_RECENT ] && eval `cat $SSH_RECENT`
5 if [ ! -z "$SSH_AGENT_PID" ]
7 RUNNING_AGENTS=`ps -p $SSH_AGENT_PID | grep -v CMD | wc -l`
9 if [ $RUNNING_AGENTS -lt 1 -a $UID -ne 0 ]
11 eval `ssh-agent`
12 echo "export SSH_AGENT_PID=$SSH_AGENT_PID" > $SSH_RECENT
13 echo "export SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $SSH_RECENT
16 [ `ssh-add -l | fgrep -v ' no ' | wc -l` -lt 1 ] && ssh-add
Can you tell me why I’m choosing to evaluate $UID for zero?
And, will this work if I switch from an Xterm to a virtual terminal?