Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Net::SSH::Any is still a work on progress and the documentation is quite lacking, but the API is mostly a subset of that of Net::OpenSSH (IIRC, new, system, capture, capture2, error and scp methods are supported) so you should read its docs.

The new method returns always an object, even when the connection fails. You have to use the error method to check for errors.

In order to use public key authentication, use the constructor option key_path to pass the path of the file containing the private key to Net::SSH::Any.

my $ssh = Net::SSH::Any->new($hostname, user => $user, key_path => "/h +ome/$user/.ssh/id_dsa"); if ($ssh->error) { say "whee...something wrong here: " . $ssh->error; } else { say " I am connected to $hostname!!!"; my @out = $ssh->capture($cmd); say "The files and directories of $username on $hostname are given + below"; say "@out"; }

Update: BTW, the module should be as fast as any other SSH client implementation (i.e. PuTTY or OpenSSH). Connecting to some machine in the same (or a near) LAN should be a sub-second operation.

Maybe sshd is configured on the Centos machine to use ident or your DNS configuration is broken or you have any other network problem or the host supporting the VM is overloaded.


In reply to Re^2: Capturing SSH output in an array. by salva
in thread Capturing SSH output in an array. by perl514

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-04-19 10:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found