use Net::SSH::Perl;
my($hostname,$username,$password,$debug) = @ARGV;
my $ssh = Net::SSH::Perl->new(
$hostname,
protocol => '2,1',
debug => $debug,
);
$ssh->login($username,$password);
my($out,$err,$ext) = $ssh->cmd("echo LOGINSUCCESSFUL");
print "out=$out err=$err ext=$ext\n";
####
% ./test.pl linux-host root password
Use of uninitialized value in concatenation (.) or string at ./test.pl line 16.
out=LOGINSUCCESSFUL
err= ext=0
####
% ./test.pl windows-host Administrator password
Use of uninitialized value in concatenation (.) or string at ./test.pl line 16.
Use of uninitialized value in concatenation (.) or string at ./test.pl line 16.
out= err= ext=255
####
% ssh -2 root@linux-host "echo LOGINSUCCESFUL"
root@linux-host's password:
LOGINSUCCESFUL
% ssh -2 Administrator@windows-host "echo LOGINSUCCESFUL"
Administrator@windows-host's password:
LOGINSUCCESFUL