Re: python3 subprocess run sudo cmd in remote failed

2019-09-17 Thread Eli the Bearded
In comp.lang.python, lampahome wrote: > what I tried many times like enter password, but it failed. > I just want to use ps.stdin.write(password) to send password, but it always > jump password prompt immediately. Passwords are frequently read from stderr, not stdin, so that tools can get a huma

Re: python3 subprocess run sudo cmd in remote failed

2019-09-16 Thread Chris Angelico
On Tue, Sep 17, 2019 at 3:25 PM Cameron Simpson wrote: > However, I repeat my recommendation to use a keypair for the > authentication, as it avoids needing interactive passwords (and having > your programme know the password has its own suite of problems to do > with where that password comes fro

Re: python3 subprocess run sudo cmd in remote failed

2019-09-16 Thread Cameron Simpson
On 17Sep2019 13:02, lampahome wrote: Note also that since stdin and stdout are pipes and not the terminal then ssh will not be interactive, and will not allocate a tty at the far end either. You can get ssh to open a remote tty with the -t option. But I suspect you don't want stdin=PIPE or stdo

Re: python3 subprocess run sudo cmd in remote failed

2019-09-16 Thread lampahome
> > Well, there's a Python library called "paramiko" which implements ssh. > That might help. > > Later I will try lol. > Note also that since stdin and stdout are pipes and not the terminal > then ssh will not be interactive, and will not allocate a tty at the far > end either. You can get ssh t

Re: python3 subprocess run sudo cmd in remote failed

2019-09-16 Thread Cameron Simpson
On 17Sep2019 12:13, lampahome wrote: Hello, I use python3.5 and found no way to solve this problem from subprocess import Popen, PIPE ps = Popen('ssh -o \'StrictHostKeyChecking no\' hello@192.168.80.11 \'sudo sysctl -w vm.drop_caches=3\', stdin=PIPE, stdout=PIPE, stderr=PIPE, bufsize=0, shell

python3 subprocess run sudo cmd in remote failed

2019-09-16 Thread lampahome
Hello, I use python3.5 and found no way to solve this problem >from subprocess import Popen, PIPE >ps = Popen('ssh -o \'StrictHostKeyChecking no\' hello@192.168.80.11 \'sudo sysctl -w vm.drop_caches=3\', stdin=PIPE, stdout=PIPE, stderr=PIPE, bufsize=0, shell=True) > hello@192.168.80.11's password