I have a script that automates a SSH session,
In that session, I am trying to sudo to another user (it works if I type it in the command line), but when I run the script, I am getting the following error:
seudo-terminal will not be allocated because stdin is not a terminal.
Warning: no access to tty (Bad file descriptor).
Thus no job control in this shell.
is there any way around this error?
sudoers have been set up so that I can su to "anotherUser" without a password, as well as the SSH key (so that I can SSH over to the host without a pw.
In that session, I am trying to sudo to another user (it works if I type it in the command line), but when I run the script, I am getting the following error:
seudo-terminal will not be allocated because stdin is not a terminal.
Warning: no access to tty (Bad file descriptor).
Thus no job control in this shell.
Code:
$HOST="myhost.com"
ssh $HOST <<END_SCRIPT
mv testfile.pl /tmp
sudo -H -u anotherUser bash
cd ~/apache2/cgi-bin
cp /tmp/testfile.pl ./
exit
END_SCRIPT
is there any way around this error?
sudoers have been set up so that I can su to "anotherUser" without a password, as well as the SSH key (so that I can SSH over to the host without a pw.