in reply to Sudo with Net::OpenSSH fails with PROCESS_MUX_NEW_SESSION: tcgetattr: Inappropriate ioctl for device
In any case, interacting with sudo is almost an art. There are too many different versions with different capabilities still in use, and then, there were several (minor) bugs related to tty handling on OpenSSH client that have been fixed only on recent releases.my $file_list = $ssh->capture({tty => 1}, "ls -l");
In the end, the only approach that is guaranteed to works in all the cases is using Expect, because you have a tty in both sides (ssh handles that without issues) and you are not using new and fancy sudo features. The downside is that using Expect is a PITA.
In summary, read the documentation for the version of sudo installed on the remote machine. Check if all the flags used by the sample code are available. Try doing it from the command line. Also, try asking Net::OpenSSH/ssh to allocate a tty on the remote side. If everything fails, go for Expect (but combined with Net::OpenSSH as explained in the docs, don't use Net::SSH::Expect that is quite buggy!).
Net::OpenSSH also has a debugging mode that could give you some hint about what is going wrong:
$Net::OpenSSH::debug = -1;
|
|---|