mkhan has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I don't know how to best put it but here is my problem:
I have two machines, Client A and a Server B.
My client is authenticated and does not need a password to connect to B normally. When I do an ssh from A to B it logs in without a password.

However,
When I use multiple parallel connections using the Parallel::Forkmanager module, it sometimes asks for password.

Here's the code I use to make connections:
Code:
use Parallel:ForkManager; my $pm=new Parallel::ForkManager(15); foreach my $processNumber (1 .. 15) { $pm->start and next; <subroutine to ssh to the server and perform some actions>; $pm->finish; } $pm->wait_all_children;
Every process has about 5000 more iterations of creating some tables etc.
Intermittently, it asks for password to authenticate the client when it normally does not.

What could be the problem? Any help is appreciated.
  • Comment on Server prompts for password even though client is authenticated when Parallel::ForkManager is used
  • Download Code

Replies are listed 'Best First'.
Re: Server prompts for password even though client is authenticated when Parallel::ForkManager is used
by salva (Canon) on Sep 12, 2011 at 20:10 UTC
    Show some real code, and also tell us what do you mean by "My client is authenticated" exactly!

    Are you calling ssh via system or using any of the Perl SSH modules?

    Try limiting the number of children to 9.

      There's no real relevant code really. In the subroutine I'm just making ssh connection to the server. "ssh hostname.domain.com" and executing some simple commands. I'm using ssh in simple backquotes `ssh hostname.domain.com`
        The solution to this kind of problems usually lays on the details, so unless you tell us everything it is going to be pretty difficult to help you.

        The code you have posted so far, is almost identical to the boilerplate code from Parallel::ForkManager synopsis, it is well tested and works so the error should be in other place.

Re: Server prompts for password even though client is authenticated when Parallel::ForkManager is used
by Anonymous Monk on Sep 12, 2011 at 20:00 UTC

    What could be the problem? Any help is appreciated.

    Maybe you need require ..ssh..; instead of use

    Maybe ENV{HOME} gets deleted or something

    The answer lies in the code you omitted :) line 42

Re: Server prompts for password even though client is authenticated when Parallel::ForkManager is used
by zentara (Cardinal) on Sep 13, 2011 at 11:21 UTC
    My client is authenticated and does not need a password .... Intermittently, it asks for password to authenticate the client when it normally does not.

    Can you tell whether the password it is asking for is the authentication key password, or a conventional login password? I assume from your description that you are using keys authorization for your automatic logins. What does the password request look like?

    Enter passphrase for key '/home/mkhan/.ssh/id_rsa': or Enter password for user mkhan

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
      The password request just looks like this:

      Password:

      That's all. Not a word more. I'm in a position where I can't post the code in public.
      I am using AUTH keys btw - id_rsa and id_dsa.
Re: Server prompts for password even though client is authenticated when Parallel::ForkManager is used
by ikegami (Patriarch) on Sep 13, 2011 at 18:25 UTC

    Maybe some object is created in the parent or some library is loaded in the parent, and it's sensitive to which process did so (for whatever reason).

    Try to do everything relating to create the connection in the child. That includes loading modules. (Keep in mind that moving a use into the loop isn't going to help achieve that goal. You'll need to switch to require.)