I\'m trying to automate the setup of SFTP access. This script is running as a user with sudo permissions and no password.
I can create a user like so:
You forgot this:
stdin=subprocess.PIPE
To send data to the process, you need a stdin.
stdin
So the full statement is:
process = subprocess.Popen(['sudo', 'chpasswd'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
and then call communicate('password').
communicate('password')