Mbuffer Trickery

Am rather disappointed that mbuffer isn’t shipped in CentOS 7. Easy enough to install, but seriously useful to have updated software in this day in age.

Anyhow, to use mbuffer for a long transfer where an outgoing connection was the only option, I finally found a situation where I wanted to use a fifo.

dmzhost$ mkfifo /tmp/tarfifo
lanhost$ ssh dmzhost "cat /tmp/tarfifo" | mbuffer -P90 -m512M | tar xf -
dmzhost$ tar cf - pub | mbuffer -P90 -m128M > /tmp/tarfifo

And there we have it.

Advertisements

Checking for your ssh-agent on login – updated

The first thing my .bash_aliases file does on login is to check if I’m running ssh-agent and if so, stick that into my shell environment. If not, kick it up, and update a reminder to it. This morning I found a flaw in that, so I believe this is the fix.

  4 export SSH_RECENT="$HOME/.ssh/recent"
  5 [ -f "$SSH_RECENT" ] && eval `cat $SSH_RECENT`
  6 RUNNING_AGENTS=0
  7 if [ ! -z "$SSH_AGENT_PID" ]
  8 then
  9    RUNNING_AGENTS=`pgrep -u $(id -u) ssh-agent | grep $SSH_AGENT_PID | wc -l`
 10 fi
 11 if [ $RUNNING_AGENTS -lt 1 -a $UID -ne 0 ]
 12 then
 13    eval `ssh-agent`
 14    echo "export SSH_AGENT_PID=$SSH_AGENT_PID" >    $SSH_RECENT
 15    echo "export SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >>   $SSH_RECENT
 16 fi
 17 [ `ssh-add -l | fgrep -v ' no ' | wc -l` -eq 0 ] && ssh-add

Return of the 007 SSH Agent

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:

  1 #!/bin/bash
2 export SSH_RECENT="$HOME/.ssh/recent"
3 [ -f $SSH_RECENT ] && eval `cat $SSH_RECENT`
4 RUNNING_AGENTS=0
5 if [ ! -z "$SSH_AGENT_PID" ]
6 then
7 RUNNING_AGENTS=`ps -p $SSH_AGENT_PID | grep -v CMD | wc -l`
8 fi
9 if [ $RUNNING_AGENTS -lt 1 -a $UID -ne 0 ]
10 then
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
14 fi
15
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?