I have a number of centralized scripts, which install certain pieces of middleware (for example JBoss-AS, JBoss-EWS, etc). The idea is to use expect to write a script which runs the script (which can contain serveral commands and if ... then ... else, as well as loop structures) on another server, under an other user.
What I need is an expect script which executes something like this:
central $ ssh <user>@<remote> "sudo local-script"
I have tried to pipe things in like
cat local-script | ssh -t <user>@<remote> sudo, but sudo won't allow this. When I get the above sequence, i.e. run
sudo local-script through a ssh channel, then I can use autoexpect to generate an expect file which works (also things like
ssh -t <user>@<remote> sudo < cat local-script doesn't work.
I know you can use this to run commands that are on the remote server, so that is not my question.
Since most of the install scripts we use need root permissions, and because you do not use NOPASSWD for root for obvious reasons, is this possible, and how?