errors when running multiple openssh sessions

Dan Kaminsky dan at doxpara.com
Tue Jun 17 06:08:59 EST 2003


jcduell at lbl.gov wrote:

>Openssh seems to fail sporadically if you issue lots of simultaneous
>ssh commands, at least under certain conditions.  Take the following
>program:
>
>    #!/bin/sh
>
>    for NUM in 0 1 2 3 4 5 6 7 8 9; do 
>        ssh n2003 echo $NUM "$*" &
>    done
>
>So, we're running 10 ssh commands at once.  
>
>When I run this program once, all 
>
>
>
>I've observed this bug on OpenSSH_3.6.1p1 on Tru64, OpenSSH 3.2.3p1 on
>an IBM SP, and on OpenSSH 3.5p1-6 on Redhat Linux 9. So I suspect it's a
>general problem.
>
>  
>
That invocation creates quite a spike in CPU usage.  Who knows, it might 
also be causing headaches for privsep.  A better way to do what you 
describe above would be this:

#!/bin/sh

for NUM in 0 1 2 3 4 5 6 7 8 9; do
        echo $NUM "$*" \&
done | ssh n2003

 From what I've found, this is the best way to execute sets of commands 
remotely without significant CPU load.  You do lose all sorts of 
conveniences -- error codes, the ability to distinguish between the 
results of several commands, standard syntax for specifying shell -- but 
you're losing most of that from parallel execution anyway, and this is 
really quite fast.

Of course, ssh shouldn't crash no matter what.  But this might be of use 
regardless.

--Dan







More information about the openssh-unix-dev mailing list