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"
echo 'password' | sudo -S command
-S accepts password from stdin