title: Python + pexpect - How to establish a ssh connection?
body: <p>I've been trying to establish an ssh connection via Python + pexpect, but I can't send the lines that I want.</p>
  
  <p>I think it's certainly a syntax problem, but I don't know where it is occurring. </p>
  
  <pre><code>#! /usr/bin/python # -*- encoding: utf-8 -*-
  import re
  import pexpect
  import sys
  
  
  
  child = pexpect.spawn ("gnome-terminal -e 'bash -c \"ssh -X user@localhost; exec bash\"'")
  child.expect ("user@localhost\"''s password.*:\"'")
  child.sendline ('xxyyzz')
  
  print "OK"
  </code></pre>
  
  <p>The problem is that the password 'xxyyzz' never appears on the terminal, so I think the <code>child.sendline</code> doesn't work and is a syntax problem.</p>