title: Rsync "permission denied" error using Vagrant's docker provider on Windows
body: <p>Just installed vagrant 1.7.4 from official website, besides other software: Virtual Box, cygwin(rsync and openssh). Other boxes like ubuntu/trusty or centos/7 seem to work. Error came up when I tried to use docker as provider.
  Here's my vagrant file</p>
  
  <pre><code>Vagrant.configure(2) do |config|        
    config.vm.network "public_network", ip: "192.168.1.103" 
    config.ssh.insert_key=true
    config.vm.provider "docker" do |d|
      #d.vagrant_vagrantfile = "vagrantfile-boot2docker"  
      d.build_dir = "."
    end
    ENV["VAGRANT_DETECTED_OS"] = ENV["VAGRANT_DETECTED_OS"].to_s + " cygwin"
  end
  </code></pre>
  
  <p>Here's what's going on in console.</p>
  
  <blockquote>
  <pre><code>$ vagrant up
  Bringing machine 'default' up with 'docker' provider...
  ==&gt; default: Docker host is required. One will be created if necessary...
      default: Docker host VM is already ready.
  ==&gt; default: Syncing folders to the host VM...
      default: The machine you're rsyncing folders to is configured to use
      default: password-based authentication. Vagrant can't script rsync to automatically
      default: enter this password, so you'll likely be prompted for a password
      default: shortly.
      default:
      default: If you don't want to have to do this, please enable automatic
      default: key insertion using `config.ssh.insert_key`.
      default: Rsyncing folder: /cygdrive/f/st***/Pre*****/ =&gt; /var/lib/docker/docker_1447743654_45276
  There was an error when attempting to rsync a synced folder.
  Please inspect the error message below for more info.
  
  Host path: /cygdrive/f/st***/Pre*****/
  Guest path: /var/lib/docker/docker_1447743654_45276
  Command: rsync --verbose --archive --delete -z --copy-links --chmod=ugo=rwX --no-perms --no-owner --no-group --rsync-path sudo rsync -e ssh -p 2201 -o StrictHostKeyChecking=no -o
  IdentitiesOnly=true -o UserKnownHostsFile=/dev/null --exclude 
  .vagrant/ /cygdrive/f/st***/Pre*****/
  docker@127.0.0.1:/var/lib/docker/docker_1447743654_45276
  Error: Warning: Permanently added '[127.0.0.1]:2201' (ECDSA) to the list of known hosts.
  Permission denied, please try again.
  Permission denied, please try again.
  Permission denied (publickey,password,keyboard-interactive).
  rsync: connection unexpectedly closed (0 bytes received so far) [sender]
  rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.1]
  </code></pre>
  </blockquote>
  
  <p>As I understand problem with permissions, but I am not sure what permissions boot2docker's or host's. 
  I'm also tried without config.ssh.insert_key=true - same result.</p>
  
  <p><strong>Update:</strong><br/>
  Tried to execute big rsync command from log manually. Error was shown</p>
  
  <blockquote>
    <p>connect to host 127.0.0.1 port 22: Connection refused</p>
  </blockquote>
  
  <p>but direct connection using <strong>ssh docker@127.0.0.1 -p 2201</strong> was successfull. </p>
  
  <p>So maybe problem is rsync command uses incorrect port. </p>
  
  <p><strong>Update2</strong> <br/>
  Finally,  <code>rsync -e 'ssh -p 2201' --rsync-path='sudo rsync' -avz /cygdrive/f/st***/Pre****/ docker@127.0.0.1:/var/lib/docker/docker_1447763422_11407</code> synced everything as it should be without any problem. But question is open why vagrant is not doing it properly.</p>