title: Recursive SFTP listdir in Python?
body: <p>I need to recursively list the content of a directory that contains a lot of subdirectories (more than 16,000).</p>
  
  <p>I am currently using <a href="http://docs.paramiko.org/en/2.4/api/sftp.html" rel="nofollow noreferrer">Paramiko's SFTP client</a>, which doesn't offer any recursive <code>listdir</code> functionality. So I have to first run <code>listdir</code> on the parent folder, and then another <code>listdir</code> for each of the (many, many) subdirectories. It takes too long to run.</p>
  
  <p>Is there any way to run the recursive <code>listdir</code> in a single SFTP call? I'm not limited to the Paramiko package, it's just the package that we're currently using.</p>
  
  <p>I cannot use Paramiko's <code>ssh.exec_command('ls -R &lt;path&gt;')</code> due to local administrative restrictions (it would just return an error message).</p>