title: Connecting to SFTP client using proxy command in Python
body: <p>I need to connect to SFTP server using proxy command.</p>
  
  <p>I know how to connect to SFTP server directly:<br>
  <a href="https://stackoverflow.com/q/3635131/850848">paramiko&#39;s sshclient with sftp</a></p>
  
  <p>I can open an SSH connection via proxy command using this code:</p>
  
  <pre><code>import paramiko
  client = paramiko.SSHClient()
  client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  target_host = 'sftp.XXXXX.co'
  target_port = 22
  proxy = paramiko.proxy.ProxyCommand('/usr/bin/nc --proxy proxy_host:8080 %s %d' % (target_host, target_port) )
  client.connect(hostname=target_host,username='username', port=target_port, password='XXXXXXXX', sock=proxy)
  </code></pre>
  
  <p>But I need to create <code>SFTPClient</code>, not <code>SSHClient</code>. But I do not know how to pass the <code>ProxyCommand</code> to the <code>SFTPClient</code>.</p>