Consider the following command
ssh aristotle sudo /bin/sh < test.sh
I want the redirection to apply to /bin/sh but it is consumed by sudo. Any ideas on how to achieve what I want?
Jonathan Gossage
|
feedback
|
|
Why not just copy over test.sh and then invoke it?
The $$ is the PID of the process on the local machine, giving some degree of randomness so your file doesn't get clobbered. | ||||
|
feedback
|
|
Try this way:
| |||||||
feedback
|
| ||||
|
feedback
|
|
I used
| ||||
|
feedback
|
|
Likely, sudo is prompting for a password and its trying to get it from your test.sh script. There's two solutions. First, you can assign NOPASSWD for your userid on the target system.
Or second, you can ssh to the system and provide a password to sudo, then run it again and
Of course, you'll want to take precautions about your password appearing in your shell history (such as put it in a file only you have access to, then get the value from that file via cat or similar). I strongly prefer the former, with SSH key-based authentication only, no passwords at all, and the private key residing on one system: my laptop (protected with a 16+ character passphrase). Contents of my test.sh:
| ||||
|
feedback
|
<– Dennis Williamson Jul 9 '09 at 1:12