my %SSH_Prm = ( "protocol" => '2', "use_pty" => 0, "options" => ["stricthostkeychecking no"], "identity_files" => ["/home/user/.ssh/id_rsa"], "debug" => 1, ); my $ssh = Net::SSH::Perl->new($server,%SSH_Prm); $ssh->login("deploy"); my ($out,$err,$exit) = $ssh->cmd("/usr/bin/sudo $command");