Hello Monks,

I am using the Net::OpenSSH::Parallel module to create parallel ssh connections. Note that the module is using the Net::OpenSSH to create ssh sessions. So far I have successfully used in the past for multiple scripts by using password => $password in public the username and password to automate ssh connections

As stated on the documentation: Note that using password authentication in automated scripts is a very bad idea. When possible, you should use public key authentication instead. it is much safer to use ssh key authentication.

I am able to ssh to my localhost through the typical way

ssh -p 22 user@host</p> without password as I have set up the ssh key +authentication.</p> <p>When I am using the module <code>Net::OpenSSH::Parallel
to automate the connections without password but with ssh-key on debug mode -1 $Net::OpenSSH::Parallel::debug = -1;, I keep getting this error:

0.488| [192.168.24.16] added (HASH(0x19e5f70)) 0.488| [192.168.24.16] state set to done 0.488| selector(*) --> [192.168.24.16] 0.488| [192.168.24.16] action command queued 0.488| [192.168.24.16] state changed done --> ready 0.488| run: iterating... 0.488| run: hosts at connecting: 0 0.488| run: hosts at ready: 1 0.488| num workers: 1, maximum: 1 0.488| [192.168.24.16] at_ready 0.488| [192.168.24.16] at_ready, starting new action command 0.488| [192.168.24.16] host is not connected, connecting... 0.488| [192.168.24.16] _connect, starting SSH connection Invalid or bad combination of options ('key_path') at parallel_ssh.pl +line 41.

I wrote a small script to demonstrate the problem that I am having:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Net::OpenSSH::Parallel; $Net::OpenSSH::Parallel::debug = -1; my %hosts = ( 'localhost' => { host => "127.0.0.1", user => "user", port => "22", psw => "psw", key => "/home/user/.ssh/id_rsa", }, ); my $maximum_workers = scalar (keys %hosts); my $maximum_connections = 2 * $maximum_workers; my $maximum_reconnections = 0; my %opts = ( workers => $maximum_workers, connections => $maximum_connections, reconnections => $maximum_reconnections ); my $pssh = Net::OpenSSH::Parallel->new( %opts ); foreach my $label (keys %hosts) { $pssh->add_host( #$hosts{$label}, $hosts{$label}{host}, user => $hosts{$label}{user}, port => $hosts{$label}{port}, password => $hosts{$label}{psw}, key_path => $hosts{$label}{key}, ); } #print Dumper $pssh; $pssh->push('*', command => 'ls'); $pssh->run;

If someone searches for the same error online he will find multiple links for similar errors but none of them providing the solution to the problem, example links (Re: net::openssh error in CGI: Invalid or bad combination of options ('key_path')). The only useful link that I found is (how to use Net::SSH::Perl with public keys?).

The error is coming from the module Net::OpenSSH (github link) at line 69.

Anyone ever encounter this problem, and if so does anyone know how to overcome the problem?

Thanks in advance for your time and effort reading and replying to my question.

Update: ok I just found the solution to my problem (stupid of me). I just thought that might provide some help to someone in future that is the only reason that I am posting this.

Solution: simply since you obviously using ssh-key what is the purpose to use password. Simply comment out the password input when you add another user or simply do not provide it.

End of update

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Invalid or bad combination of options ('key_path') [RESOLVED] by thanos1983

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.