use Net::OpenSSH; my $ssh = Net::OpenSSH->new($host, user => $user, password => $password); $ssh->system({tty => 1}, 'sudo -s');