title: Paramiko hangs on ssh.open_sftp()
body: <p>I have the following script that I try to run:</p>
  
  <pre><code>import paramiko
  import os
  
  host, port, user, passw, key = .... 
  
  transport = paramiko.Transport((host, port))
  ssh = paramiko.SSHClient()
  ssh.load_system_host_keys()
  ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  
  private_key_file = key
  paramiko.util.log_to_file("filename.log")
  xSx_key = paramiko.RSAKey.from_private_key_file(private_key_file,None)
  transport.connect(username = user, password=passw, pkey = xSx_key)
  ssh.connect(host, username=user, password=passw, pkey=xSx_key, port=port) 
  
  
  ftp = ssh.open_sftp()
  files = ftp.listdir()
  </code></pre>
  
  <p>Unfortunately this hangs during the open_sftp() call. If I subsequently do a KeyboardInterrupt, I get the following stacktrace:</p>
  
  <pre><code>  ftp = ssh.open_sftp()
    File "build\bdist.win-amd64\egg\paramiko\client.py", line 379, in open_sftp
    File "build\bdist.win-amd64\egg\paramiko\transport.py", line 811, in open_sftp_client
    File "build\bdist.win-amd64\egg\paramiko\sftp_client.py", line 128, in from_transport
    File "build\bdist.win-amd64\egg\paramiko\transport.py", line 615, in open_session
    File "build\bdist.win-amd64\egg\paramiko\transport.py", line 726, in open_channel
    File "C:\Anaconda\lib\threading.py", line 620, in wait
      self.__cond.wait(timeout)
    File "C:\Anaconda\lib\threading.py", line 358, in wait
      _sleep(delay)
  KeyboardInterrupt
  </code></pre>
  
  <p>The paramiko logfile shows the following,</p>
  
  <pre><code>DEB [20150702-17:22:11.519] thr=1   paramiko.transport: starting thread (client mode): 0x32a00f0L
  INF [20150702-17:22:11.604] thr=1   paramiko.transport: Connected (version 2.0, client SSHD)
  DEB [20150702-17:22:11.686] thr=1   paramiko.transport: kex algos:[u'diffie-hellman-group14-sha1', u'diffie-hellman-group1-sha1', u'diffie-hellman-group-exchange-sha1'] server key:[u'ssh-rsa'] client encrypt:[u'aes256-cbc', u'aes192-cbc', u'aes128-cbc', u'3des-cbc'] server encrypt:[u'aes256-cbc', u'aes192-cbc', u'aes128-cbc', u'3des-cbc'] client mac:[u'hmac-sha1', u'hmac-sha1-96'] server mac:[u'hmac-sha1', u'hmac-sha1-96'] client compress:[u'none', u'zlib'] server compress:[u'none', u'zlib'] client lang:[u''] server lang:[u''] kex follows?False
  DEB [20150702-17:22:11.687] thr=1   paramiko.transport: Ciphers agreed: local=aes128-cbc, remote=aes128-cbc
  DEB [20150702-17:22:11.687] thr=1   paramiko.transport: using kex diffie-hellman-group14-sha1; server key type ssh-rsa; cipher: local aes128-cbc, remote aes128-cbc; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none
  DEB [20150702-17:22:12.020] thr=1   paramiko.transport: Switch to new keys ...
  DEB [20150702-17:22:12.026] thr=2   paramiko.transport: Attempting public-key auth...
  DEB [20150702-17:22:12.188] thr=1   paramiko.transport: userauth is OK
  INF [20150702-17:22:14.894] thr=1   paramiko.transport: Auth banner: &lt;cut&gt;
  
  INF [20150702-17:22:15.078] thr=1   paramiko.transport: Authentication continues...
  DEB [20150702-17:22:15.078] thr=1   paramiko.transport: Methods: [u'password', u'publickey', u'keyboard-interactive']
  DEB [20150702-17:22:15.168] thr=3   paramiko.transport: starting thread (client mode): 0x33263c8L
  INF [20150702-17:22:15.253] thr=3   paramiko.transport: Connected (version 2.0, client SSHD)
  DEB [20150702-17:22:15.335] thr=3   paramiko.transport: kex algos:[u'diffie-hellman-group14-sha1', u'diffie-hellman-group1-sha1', u'diffie-hellman-group-exchange-sha1'] server key:[u'ssh-rsa'] client encrypt:[u'aes256-cbc', u'aes192-cbc', u'aes128-cbc', u'3des-cbc'] server encrypt:[u'aes256-cbc', u'aes192-cbc', u'aes128-cbc', u'3des-cbc'] client mac:[u'hmac-sha1', u'hmac-sha1-96'] server mac:[u'hmac-sha1', u'hmac-sha1-96'] client compress:[u'none', u'zlib'] server compress:[u'none', u'zlib'] client lang:[u''] server lang:[u''] kex follows?False
  DEB [20150702-17:22:15.335] thr=3   paramiko.transport: Ciphers agreed: local=aes128-cbc, remote=aes128-cbc
  DEB [20150702-17:22:15.335] thr=3   paramiko.transport: using kex diffie-hellman-group14-sha1; server key type ssh-rsa; cipher: local aes128-cbc, remote aes128-cbc; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none
  DEB [20150702-17:22:15.671] thr=3   paramiko.transport: Switch to new keys ...
  DEB [20150702-17:22:15.680] thr=2   paramiko.transport: Adding ssh-rsa host key for [&lt;cut&gt;]:&lt;cut&gt;: e5025a02b8ca851f7f0a2d173161400c
  DEB [20150702-17:22:15.680] thr=2   paramiko.transport: Trying SSH key 4e85b76b311684e139c597cbab111fef
  DEB [20150702-17:22:15.841] thr=3   paramiko.transport: userauth is OK
  INF [20150702-17:22:19.246] thr=3   paramiko.transport: Auth banner: &lt;cut&gt;
  
  INF [20150702-17:22:19.426] thr=3   paramiko.transport: Authentication continues...
  DEB [20150702-17:22:19.427] thr=3   paramiko.transport: Methods: [u'password', u'publickey', u'keyboard-interactive']
  DEB [20150702-17:22:19.438] thr=2   paramiko.transport: [chan 0] Max packet in: 32768 bytes
  WAR [20150702-17:22:19.526] thr=3   paramiko.transport: Oops, unhandled type 3
  DEB [20150702-17:22:35.707] thr=1   paramiko.transport: EOF in transport thread
  DEB [20150702-17:22:35.726] thr=3   paramiko.transport: EOF in transport thread
  </code></pre>
  
  <p>I wonder if the "unhandled type 3" is any hint? The server I am trying to connect to requires user, pass and keyfile.</p>
  
  <p>Any suggestion would be much appreciated, as I'm quite at a loss here. Note that I can connect to this server without issue using, e.g., WinSCP.</p>
  
  <p>Thanks!</p>
  
  <p>-Joris.</p>