0

I'm using Python subprocess to run a command on a remote server:

p=subprocess.Popen('ssh [email protected] "sudo do_something"', shell=True) 

When I type the password, it appears on the screen - as opposed to running this from the shell, where the password is hidden.

Is there a way to disable this input echo?

2
  • 1
    you may want to consult to this thread stackoverflow.com/questions/1787288/… Commented Mar 19, 2012 at 9:55
  • fabric might be useful to run a command on a remote server. Commented Mar 19, 2012 at 10:20

1 Answer 1

1

You might want to consider using pexpect if you have to type something that should be automated: http://www.noah.org/wiki/Pexpect This way you can ask your user in advance for the password (using the getpass module), and then let your script "type" the password virtually.

There are a couple of well written examples on the website mentioned above describing how to do what you need.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.