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?

2

1 Answer 1

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

2
  • Well, that was easier than I expected. Aug 21, 2016 at 17:35
  • @SodAlmighty - you might have a look at the link in Kenster's second comment for a discussion of security concerns(in the comments).
    – seph
    Aug 21, 2016 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.