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/bash
set -x
sudo env
I can run the sudo
command locally without password:
[user@server]$ sudo env
VAR=VAL
...
I can run the script locally:
[user@server]$ /tmp/testSudo.sh
+ sudo env
VAR=VAL
...
I can run sudo
on the remote host:
[user@client]$ ssh user@server sudo env
VAR=VAL
...
I can run the script on the remote host with tty:
[user@client]$ ssh -t user@server /tmp/testSudo.sh
+ sudo env
VAR=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 env
It hangs there.
ssh -t
? – Gilles 'SO- stop being evil' Jul 17 '13 at 23:47