2

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, sudo 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 sudo into allowing this?

Sod Almighty
  • 1,768
  • 1
  • 16
  • 29
  • Possible duplicate of [proper way to sudo over ssh](http://stackoverflow.com/questions/10310299/proper-way-to-sudo-over-ssh) – Kenster Aug 21 '16 at 17:30
  • See also http://stackoverflow.com/questions/233217/how-to-pass-the-password-to-su-sudo-ssh-without-overriding-the-tty – Kenster Aug 21 '16 at 17:30

1 Answers1

6

found here: https://askubuntu.com/questions/470383/how-to-avoid-prompt-password-for-sudo

echo 'password' | sudo -S command

-S accepts password from stdin

Community
  • 1
  • 1
seph
  • 6,066
  • 3
  • 21
  • 19