I\'m trying to execute a command remotely via SSH from Python, and in this particular case need stdin to be redirected to /dev/null.
That is, the same as us
Unless I understand your question incorrectly: you don't need to achieve this. Nothing is automatically read from stdin/written to the remote process' stdin unless you yourself explicitly do so. So you don't need to prevent reading from stdin from happening?
EDIT: there might be an issue if the remote process expects data on stdin, and keeps waiting for it? Try calling shutdown_write()
on the channel:
stdin, stdout, stderr = client.exec_command(cmd)
stdin.channel.shutdown_write()