in reply to Net:SSH2 channels
. 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...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Net:SSH2 channels
by BernieC (Pilgrim) on Aug 07, 2018 at 23:42 UTC | |
by syphilis (Archbishop) on Aug 08, 2018 at 02:02 UTC | |
by BernieC (Pilgrim) on Aug 08, 2018 at 14:02 UTC | |
by syphilis (Archbishop) on Aug 09, 2018 at 11:25 UTC | |
Re^2: Net:SSH2 channels
by Anonymous Monk on Aug 08, 2018 at 02:05 UTC |