how to speed up OpenSSH command execution (and a speed analysis)

Ángel González keisial at gmail.com
Mon Mar 26 08:27:11 EST 2012


On 25/03/12 21:51, Christoph Anton Mitterer wrote:
> BUT
>
> - When the FIRST time, I execute a command, -t is NOT used,... then
> speed stays at the boring 0.045s.
> - For subsequent tries (with the same Control Master)... it doesn't
> matter whether -t is used or not,.. it stays at around 0.045s.
>
>
> CONCLUSIONS:
> I) Something seems to be fishy there, given that it
>    * depends on the FIRST command executed using -t
>    * while most other options get "fix" by starting the ControlMaster
>      the -t option seem to be not "set" by it.
> II) With -t (and ControlMaster) you can speed up SSH dramatically
> (effectively making NRPE absolutely useless).
Maybe your nrpe command behaves differently if it is run with a
pseudo-terminal ?
I don't know why it would be slower the second time, but perhaps it
could be detecting
that it an "already used terminal" and trying to clean that (opening yet
another
terminal? creating a new process group?), which end up being expensive.

What are the results when you employ a different command?

I open the master with:
 SSH_ASKPASS=true ssh -f -o ControlMaster=yes
-oControlPath=/tmp/localhost -M localhost -N

Then run
 time  ssh  -oControlPath=/tmp/localhost localhost true
or
 time  ssh -t  -oControlPath=/tmp/localhost localhost true

I get about 0m0.008s for the non-tty case and 0m0.009s with -t
(with some deviations, there are -t of 0.008s and yet in some cases it
is up to 0.011s)
which is consistent with the fact that it needs to do more work when
allocating a tty.



> PROBLEMS LEFT:
> Apart from the strange point (I) above... (shall I open a bug on this?)
> there is one "big" problem left:
> Whenever I use "-t" in the command execution step (that was (2) above) I
> first get the output from the script, e.g.:
>
>    # time /usr/lib/nagios/plugins/check_nrpe  -H host.example.org -c check_load
>    OK - load average: 0.00, 0.02, 0.00|load1=0.000;15.000;30.000;0; load5=0.020;10.000;25.000;0; load15=0.000;5.000;20.000;0;
>
> but directly afterwards, ssh prints the following on stderr:
>    Shared connection to host.example.org closed.
Call the client ssh with -q parameter to remove this diagnostic.

Best regards



More information about the openssh-unix-dev mailing list