#!/usr/bin/perl -w use strict; use Net::SSH::Perl; my $sshusername = "anthski"; my $sshpasswd = "somepassword"; my $host = "192.168.0.1"; my $command = "date"; my $ssh = Net::SSH::Perl->new($host, debug => 1, protocol => 2); my $loginStatus = $ssh->login($sshusername,$sshpasswd); my $stdout; my $stderr; my $exit; eval { ($stdout,$stderr,$exit) = $ssh->cmd($command); }; if ($@) { if ($@ =~ m/Permission denied/i) { print "Authentication failed\n"; exit 1; } } print "$stdout\n";