morya has asked for the wisdom of the Perl Monks concerning the following question:
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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: fork more than MaxSessions times in Net::OpenSSH
by salva (Canon) on Sep 02, 2011 at 07:37 UTC | |
by morya (Initiate) on Sep 02, 2011 at 08:06 UTC |