I have an AIX 6.1 server where I need to run a remote sudo command in a bash script.Here is my bash script simplified:testSudo.sh#!/usr/bin/bashset -xsudo envI can run the sudo command locally without password:[user@server]$ sudo envVAR=VAL...I can run the script locally:[user@server]$ /tmp/testSudo.sh+ sudo envVAR=VAL...I can run sudo on the remote host:[user@client]$ ssh user@server sudo envVAR=VAL...I can run the script on the remote host with tty:[user@client]$ ssh -t user@server /tmp/testSudo.sh+ sudo envVAR=VAL...I can't run the script on the remote host without tty (and I can't add the -t option in my context):[user@client]$ ssh user@server /tmp/testSudo.sh+ sudo envIt hangs there.
sudo hangs when run on remote host over ssh in a script without tty (-t)
bash;ssh;sudo;aix