$ssh2->auth_password($login{user}, $login{password})
or die "Auth failed";
####
$ssh2->auth_ok() or die "Not authorized";
##
##
use warnings;
use Net::SSH2;
use strict;
my @output;
my $ssh = Net::SSH2->new();
$ssh->connect("host") or die "Unable to connect host\n";
# auth_password no longer working for me
# $ssh->auth_password("user", "password")
# or die "Failed to auth\n";
# using auth_publickey works
$ssh->auth_publickey(
"user",
"C:\\cygwin\\home\\user\\.ssh\\id_rsa.pub",
"C:\\cygwin\\home\\user\\.ssh\\id_rsa",
0)
or die "Auth failed";
die "Not authenticated"
unless $ssh->auth_ok; # Double checking
my $channel = $ssh->channel()
or die "Channel creation failed\n";
$channel->blocking(1);
$channel->exec("ls ~");
while (<$channel>) {push @output, $_}
print scalar @output, "\n"; # See no. of entries
print for @output;