title: Is it possible to use os.walk over SSH?
body: <p>I'm new to Python so forgive me if this is basic, I've searched but can't find an answer. I'm trying to convert a Perl script into Python (3.x) which connects to a remote server and copies the files in a given directory to the local machine. Integrity of the transfer is paramount and there are several steps built-in to ensure a complete and accurate transfer.</p>
  
  <p>The first step is to get a complete listing of the files to be passed to rsync. The Perl script has the following lines to accomplish this:</p>
  
  <pre><code>@dir_list = `ssh user@host 'find $remote_dir -type f -exec /bin/dirname {} \\;'`;
  @file_list = `ssh user@host 'find $remote_dir -type f -exec /bin/basename {} \\;'`;
  </code></pre>
  
  <p>The two lists are then <code>join</code>ed to create $full_list.</p>
  
  <p>Rather than  open two separate <code>ssh</code> instances I'd like to open one and use <code>os.walk</code> to get the information using:</p>
  
  <pre><code>for remdirname, remdirnames, remfilesnames in os.walk(remotedir):
      for remfilename in remfilesnames:
          remfulllist.append(os.path.join(remdirname, remfilename))
  </code></pre>
  
  <p>Thank you for any help you can provide.</p>