Hello everyone!

Greetings!

Recently, I am using Net::OpenSSH for my work. And I run to this problem...

I created an $ssh object and then fork a lot children processes which use this object.

When the children number is bigger than "MaxSessions" sshd configuration, some children process prompt user for confirming password when no more channels could be created by sshd.

I reviewed the src of Net::OpenSSH _connect method, and did found NumberOfPasswordPrompts parameter, but I don't know if this could affect the multiplexing session of ssh.

What could I do to avoid the password prompt from forked child or am I using this module wrong?

The following lines are my test code.

Any comments is appreciated, thanks for read along this line...

:)

#!/usr/bin/perl use strict; use warnings; use Net::OpenSSH; sub link_ssh { my $ssh = shift; $ssh->error and die "Couldn't establish SSH connection: " . $ssh->error . "\n"; my @lines = $ssh->capture(qq{ps}); print @lines; } sub main { my $host = "morya:morya\@10.137.73.214"; my $ssh = Net::OpenSSH->new( $host ); my @childs = (); # most hosts use MaxSessions=10 as default for ( 1 .. 12 ) { my $kid = 1; $kid = fork; push( @childs, $kid ) if ($kid); if ( !$kid ) { # child process eval { link_ssh $ssh, $_; }; if ($@) { print "child $_ ERR $@\n"; } exit; } } print "main $$ waiting childs\n"; waitpid( $_, 0 ) foreach @childs; return 0; } exit(main);

In reply to fork more than MaxSessions times in Net::OpenSSH by morya

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.