title: paramiko.Proxycommand fails to setup socket
body: <p>I am trying to connect via SSH to a computer tunneling through another computer using <a href="http://www.lag.net/paramiko/" rel="noreferrer">paramiko</a> in Python, but I am having some strange issues.
  My config file in <code>/.ssh/config</code> looks like this:</p>
  
  <pre><code>Host remoteA
  HostName 169.254.1.1
  User root
  IdentityFile ~/.ssh/id_dss.openssh.remoteA
  ForwardX11 no
  StrictHostKeyChecking no
  ForwardAgent yes
  UserKnownHostsFile /dev/null
  
  Host remoteB
  User root
  IdentityFile ~/.ssh/id_dss.openssh.remoteB
  ForwardX11 no
  StrictHostKeyChecking no
  UserKnownHostsFile /dev/null
  ProxyCommand ssh -W 169.254.1.2:22 remoteA
  </code></pre>
  
  <p>And my python code like this:</p>
  
  <pre><code>from paramiko import SSHClient, SSHConfig, SSHException
  import getpass
  import paramiko
  
  
  def getSSHConnection(hostName):
       config = SSHConfig()
  
  
       user = getpass.getuser()
       config.parse(open('C:/Users/' + user +'/.ssh/config')) 
       host=config.lookup(hostName)
  
  
       # setup SSH client
       client = SSHClient()
       client.load_system_host_keys()
       client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  
       #Check for proxy settings
       try:
          print host ['proxycommand']
          proxy = paramiko.ProxyCommand(host['proxycommand'])
      except:
          proxy = None
      #Setup the SSH connection
      try:
          if (proxy is None):
              client.connect(host['hostname'],22, username=host['user'],key_filename=host['identityfile'])
          else:
              client.connect(host['hostname'],22, username=host['user'],  key_filename=host['identityfile'], sock=proxy)
      except SSHException, ex:
          print ex
  
      return client
  
  
  
  
  
  ssh_client = getSSHConnection('remoteA')
  
  # run a command
  print "\nRun a command"
  cmd = 'ps aux'
  stdin, stdout, stderr = ssh_client.exec_command(cmd)
  
  print stdout.read()
  
  ssh_client = getSSHConnection('remoteB')
  
  # run a command
  print "\nRun a command"
  cmd = 'ps aux'
  stdin, stdout, stderr = ssh_client.exec_command(cmd)
  
  print stdout.read()
  </code></pre>
  
  <p>First when connecting to remoteA it works perfectly, but then when connecting to remoteB it crashes in the step: <code>proxy = paramiko.ProxyCommand(host['proxycommand'])</code>.</p>
  
  <pre><code>File "C:\Python27\lib\site-packages\paramiko\client.py", line 291, in connect
      for (family, socktype, proto, canonname, sockaddr) in socket.getaddrinfo(hostname, port,         socket.AF_UNSPEC, socket.SOCK_STREAM):
  socket.gaierror: [Errno 11004] getaddrinfo failed
  </code></pre>
  
  <p>Within Cygwin, I am able to connect using the command <code>ssh remoteB</code> so I know the config file should be ok. </p>
  
  <p>If it makes any difference, I am running this on Windows 7.</p>