Hi Tim,

On 20/03/13 22:49, Tim Ash wrote:
> Thank you for your reply, it is suitable to do not change any thing in
> the server side, and the executable which I want to execute through
> ssh.exec shouting that need's sudo's permitting. Maybe my thinking could
> be wrong as I'm beginner, but it would be great if you can suggest
> anything strait-forward to get it done.

The most straightforward solution is to explore the sudo/sudoers route 
as suggested, and add a rule that will allow the command you need. It'll 
save you a lot of hassle.

If you really, really can't go this way, the options aren't that 
straightforward any more. Some possibilities are:

- Use IO.popen to run ssh, and then push the password down the pipe, 
followed by the command. You'll have to experiment to figure out the 
specifics though, as well as the best way to keep track of the password.

- Explore the use of ssh to allow passwordless access to the target 
account, perhaps through a private/public key pair.

- Write a script that runs on the target account that checks, every few 
seconds, for the presence of some lock file, or alternatively, create a 
server that sits there, waiting for connections. Your ssh command can 
hen trip that lock file, or connect to the server, to indicate you wish 
to run something.

These really are second-rate solutions compared to setting up sudo to 
accept the single command in the first place. They'll take a lot of 
extra work. I suggest you fully explore the sudoers route first if it is 
at all an option.

Good luck.

Cheers,
Garth