#!/usr/bin/perl use strict; use warnings; use Net::OpenSSH; my $username = 'user'; my $password = 'password'; my $params; $params->{cmd} = "cd /home/user/scripts"; my $session_obj; $session_obj = Net::OpenSSH->new("x.x.x.x", user => $username, password => $password, strict_mode => 0,master_opts => [ -o => "StrictHostKeyChecking=no"]); $session_obj->error and die "ssh failed: " . $session_obj->error; my ($out,$err) = $session_obj->capture2({timeout => 30}, $params->{cmd}); print "THE OUT IS $out\nTHE ERROR IS $err\n";