I'm trying to write a python script to remotely update the login passwords for a set of account I administer - I can already successfully use python to pipe remote commands via the stdin of an ssh process. However, I want to test whether the remote password is correctly set. I can do this I can do this remotely follows:
[localhost]% ssh -t -o RequestTTY=true user@host [host]% su user -c true
and provide the password at the prompt. This works, but if I try the following remotely:
[localhost]% echo "su user -c true" | ssh -t -o RequestTTY=true user@host
I get:
su: must be run from a terminal
Note, this is not failing because su needed a password (which I'll eventually provide via python) - it fails before then. su doesn't like to be run through a pipe in this way.
What's going on, and how can I pipe input to a remote su command? (or remotely test whether a password is correct for some user).
su
problem. Otherwise, you can try two-t
switches, which should force TTY allocation even when there is no terminal on local side.