in reply to Re^3: Problem using Net::OpenSSH->capture to su to another user
in thread Problem using Net::OpenSSH->capture to su to another user

Hi again,

Unfortunately the system is locked down so upgrading sudo is not an option. Anyway, adding tty >=1 seems to fix that error?

I added the master_stderr_discard option to the constructor and one of the error lines has gone away:

" muxserver_accept_control: tcgetattr: Invalid argument "

but I still get one instance of

" tcgetattr: Invalidargument "

So, using the below code I still can't seem to get access to the imail account:

my @out = $ssh->capture({ tty => 1, stdin_data => "$password\n" }, 'sudo', '-Sk', '-p', '', '--', 'su -lc "ls" imail');

Any ideas as to what I'm still doing wrong?

tim

Replies are listed 'Best First'.
Re^5: Problem using Net::OpenSSH->capture to su to another user
by salva (Canon) on Jun 04, 2014 at 11:05 UTC
    What happens when you run the following command from your local machine command line?
    echo $SUDO_PASSWORD |ssh host "sudo -Sk -p '' -- su -lc ls imail"

      Hi Salva,

      If I try that I get the below output:

      loguser@enflog01 check_apps$ echo <password> |ssh loguser@enfcdb01 "sudo -Sk -p '' -- su -lc ls imail" sudo: sorry, you must have a tty to run sudo

      tim

        oops, try again forcing a tty allocation!
        echo $PASSWD |ssh -tt loguser@enfcdb01 "sudo -Sk -p '' -- su -lc ls im +ail"

        (BTW, you may like to remove the password from your previus post)