develooper Front page | perl.beginners | Postings from January 2012

Re: Net::Openssh and sudo?

Thread Previous | Thread Next
From:
Salvador Fandiño
Date:
January 22, 2012 09:20
Subject:
Re: Net::Openssh and sudo?
Message ID:
jfhfql$g9p$1@dough.gmane.org
On 01/20/2012 08:10 PM, Rajeev Prasad wrote:
>
>
> hello,
>
> using Net::Openssh how can i use sudo to become some other user (say root) on a target machine and then execute a series of commands as root?
>
> i looked and tried to use the expect example given on Net::Openssh page but could not make it to work.
>
> my $myssh  = Net::OpenSSH->new($host,
>                                  port =>  $SSHPORT,
>                                  user =>  $USER,
>                                  password =>  $PASS,)
>
> now how can i execute a sudo on this, thus becoming a different user and, then execute bunch of commands on this handle?

Have you see the FAQ entry "Running remote commands with sudo" on the 
module documentation?

   https://metacpan.org/module/Net::OpenSSH#FAQ


It describes a simple way to run commands with sudo that doesn't require 
Expect.




Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About