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

I'm tring to automate our password changes via Net::SSH::Perl and Net::SSH::Perl::Auth

The script works fine with a hard coded login. However, when using:
my $ssh = Net::SSH::Perl->new($server, identity_files => "/root/.ssh/authorized_keys", protocol=>'2,1'); my $auth = Net::SSH::Perl::Auth->new('RSA', $ssh);

the command: my ($stdout, $stderr, $exit) = $ssh->cmd("$cmd"); fails to change the password, but appears to return with no error(after stepping thru with the debugger, the RSA authentication looks good but when printing out the variables, I get nothing back).

I tried passing the $auth ref: my ($stdout, $stderr, $exit) = $auth->cmd("$cmd"); but this errors out. Am I missing code here?

Replies are listed 'Best First'.
Re: Net::SSH::Perl::Auth problem
by salva (Canon) on Mar 31, 2011 at 15:59 UTC
    ~/.ssh/authorized_keys is used by the server side to check the keys passed by the clients during authorization.

    AFAIK, the identity_files argument should point to a file containing the list of files with the private keys used for authentication.

    And BTW, check also Net::OpenSSH.

      OK, I don't think I understand how the module is authenticating.

      After you generate an RSA key, the private key, locally, is in id_rsa. You put the public key down in authorized_keys on the remote system.

      Is it the local identity file that I'm specifying in the call?....and the Net::SSH:Perl:Auth knows to try and authenticate to the authorized_keys file?

      I'll check out the Net::OpenSSH module, but if you could elaborate, that'd be great

      Thanks, Kyle
        OK, I don't think I understand how the module is authenticating.

        After you generate an RSA key, the private key, locally, is in id_rsa. You put the public key down in authorized_keys on the remote system.

        Is it the local identity file that I'm specifying in the call?....and the Net::SSH:Perl:Auth knows to try and authenticate to the authorized_keys file?

        I'll check out the Net::OpenSSH module, but if you could elaborate, that'd be great

        Thanks, Kyle
        Is it the local identity file that I'm specifying in the call?
        Yes, and reading Net::SSH::Perl docs, it seems you have to use something like...
        identity_files => ['/root/.ssh/id_rsa']