Hi all,
I would like to do a simple script that will send a command to a server through ssh from a windows machine.
I am positive that the ssh connexion is established
but I can't see if the command was really sent, I just got no result at all.
My ref doc for doing this script: https://metacpan.org/pod/Net::SSH2
Here is my script:
#!/usr/bin/perl -w
#### Bibliothèques
use strict;
use warnings;
use Net::SSH2;
#### Variables
my $ip='X.X.X.X';
my $user='user';
my $password='passwd';
#print "IMEI: ";
#my $imei = <>;
#chomp($imei);
#my $cmd = "/opt/LSS/bin/ueadmin_cli -o delete -I $imei";
my $cmd = "ls"; # this command for testing purpose only
#### Open SSH connexion and sending command
my $ssh = Net::SSH2->new();
$ssh->connect("$ip") or die "SSH connexion Failed.\n";
if ($ssh->auth_password("$user","$password")) {
my $chan = $ssh->channel();
$chan->exec($cmd);
print while <$chan>;
$chan->close();
}else {print "authentication failed.\n";}
$ssh->disconnect;