I am trying to figure out how to use 'sudo su -' with a Net::OpenSSH. I've read the various documentation, but I am still stumped. What I want to do is log onto a box, sudo su - to a particular user, and then dump the crontab contents for that user.
Here is what I have so far -- basically, it sudos alright, but hangs before executing the crontab -l. I have to ctrl-c to get out of the script. When I ssh into the box, and sudo su - to the user manually, it works fine.
Any tips would be much appreciated. Thanks!
use strict; use warnings; use Data::Dumper; use Net::OpenSSH; my $user = 'user'; #this is just for testing -- final script will ask + for user's input. my $password = 'password'; #this is just for testing -- see above my $host = 'whater.host.to.check'; my $ssh = Net::OpenSSH->new($host, user => $user, password => $passwor +d, strict_mode => 0); my $test = $ssh->system('sudo su - user && crontab -l'); #once script + sudos, script hangs until I ctrl-c. print Dumper $test; print Dumper $ssh;
In reply to Net::OpenSSH with sudo su - by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |