I'm beginner to python and I would like to start with automation. Below is the task I'm trying to do.
ssh -p 2024 [email protected]
[email protected]'s password:
I try to ssh to a particular machine and its prompting for password. But I have no clue how to give the input to this console. I have tried this
import sys
import subprocess
con = subprocess.Popen("ssh -p 2024 [email protected]", shell=True,stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr =subprocess.PIPE)
print con.stdout.readlines()
If I execute this, output will be like
python auto.py
[email protected]'s password:
But I have no clue how to give the input to this. If some could help me out in this, would be much grateful. Also could you please help me after logging in, how to execute the commands on the remote machine via ssh.
Would proceed with my automation if this is done
I tried with con.communicate() since stdin is in PIPE mode. But no luck.
If this cant be accomplished by subprocess, could you please suggest me alternate way to execute commands on remote console(some other module) useful for automation ? since most of my automation depends on executin commands on remote console
Thanks