use strict; use warnings; use Net::SSH::Perl; use Net::SSH2; $ENV{HOME} = "PATH"; print "Server Name to Connect:"; chomp($host = ); print "User Name to Login:";chomp($LoginName = ); print "Password for $LoginName:";chomp($pswd = ); my $command = "date"; my $ssh = Net::SSH::Perl->new($host); my $status = $ssh->login($LoginName,$pswd); my $stdout; my $stderr; my $exit; if ($@) { if ($status =~ m/Permission denied/i) { print "Authentication failed\n"; print "Password for $LoginName:";chomp($pswd = ); exit 1; } } eval { ($stdout,$stderr,$exit) = $ssh->cmd($command); }; print "$stdout\n";