title: python ssh password prompt
body: <p>I am trying to get automatic password passing upon prompt while using ssh.
  normally, rsa keys are used to prevent password prompt but I can't guarantee every user is set up properly so i want the script to automatically set the password if given by the user</p>
  
  <p>Here is the </p>
  
  <pre><code>ssh = subprocess.Popen(["ssh", "localhost", "python -c 'print \"I am running\"' "], shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
  &gt;&gt;&gt; Password:
  </code></pre>
  
  <p>My tried solution was</p>
  
  <pre><code>import sys, subprocess
  
  class GetPass():
      def __init__(self, password):
         self.password=str(password)
      def readline(self):
          return self.password
  
  sys.stdin = GetPass('mypassword')
  # test raw_input 3 time to verify
  raw_input()    
  &gt;&gt; 'mypassword'
  raw_input()    
  &gt;&gt; 'mypassword'
  raw_input()    
  &gt;&gt; 'mypassword'
  
  # Now try sshing again
  ssh = subprocess.Popen(["ssh", "localhost", "python -c 'print \"I am running\"' "], shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
  &gt;&gt;&gt; Password:
  </code></pre>
  
  <p>This is not working as requesting password is still prompted.
  The idea is that GetPass replacing sys.stdin will always return the desired password automatically without the user typing it himself. </p>
  
  <p>any idea or solution ?</p>