. I gave this a shot in my environment with positive results. This is on a Linux box running v5.22.1

Most of the code is from the Synopsis on MCPAN. I tried this connecting to both a regular Linux box and a Raspberry Pi. The Pi does not have keys set up on it, but the Linux box does. I thought perhaps the auth method might be a problem when a uname/passwd combo is handed to a machine which is expecting a ssh key. But that is apparently not a problem.

Anyway, the code itself is tested and functions in my environment so, that may give you a known starting point.

Hope that is somehow helpful...

Edit:

I have not used Net::SSH previously, so this is a learning experience for me. Zentara's post is a good one. Also, there is this node which provides some really good examples to try -> A little demo for Net::SSH2

#!/usr/bin/perl use Modern::Perl; #removed no strict refs from here after originally posting.... use Net::SSH2; my ( %login, $login); my $ssh2 = Net::SSH2->new(); $login = %login; $login{'user'}='***'; $login{'password'} ='*******'; $ssh2->connect('192.168.0.15') or $ssh2->die_with_error ; $ssh2->auth_password($login{user}, $login{password}) ; $ssh2->auth_ok() ; #### print "Logged in\n" ; #### my $chan = $ssh2->channel() or ssh2->die_with_error ; my $cmd = $chan->exec('ls'); my $sftp = $ssh2->sftp(); #### my $fh = $sftp->open('.bashrc') or $sftp->die_with_error; say $_ while <$fh>; $ssh2->disconnect();

...the majority is always wrong, and always the last to know about it...

A solution is nothing more than a clearly stated problem...


In reply to Re: Net:SSH2 channels by wjw
in thread Net:SSH2 channels by BernieC

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.