Sod Almighty Sod Almighty - 1 year ago 56
Ruby Question

How to use sudo programmatically via a pipe?

I am trying to write a program to perform remote administration of a system. To this end, I issue SSH commands and provide input programmatically via a pipe. I also capture their output.

Some of the commands require elevation, so I need to issue commands such as

ssh user@host "sudo apt-get install blah"

The problem is,
refuses point-blank to accept a password via the terminal unless it finds a real terminal on its stdin. Is there some way I can fool
into allowing this?

Answer Source

found here:

echo 'password' | sudo -S command

-S accepts password from stdin