Rsync Windows Guest -> OS X Host; wrong port mapping/missing forward.

55 views
Skip to first unread message

Jim Klo

unread,
Apr 28, 2016, 7:16:54 PM4/28/16
to Vagrant
I've got an issue where I'm trying to rsync content from my Win7 guest to a OS X host and having a bit of an issue.

The Win7 guest has cygwin and ssh installed.. on the guest, I can launch a bash shell and ssh to itself without any issue.

The problem seems to be that Vagrant isn't remapping the guest ssh port such that it doesn't collide with the host's ssh port.  Hence when Vagrant tries to setup the synced_folder, I get prompted for a password, because it's trying to connect to the host, and not the guest.

Here's the relevant snippet from my Vagrant file... 

synced_folder = ENV.has_key?('SF_SYNC_DIR') ? ENV['SF_SYNC_DIR'] : "."
  build_nodes = [ "windows-build","windows-build-cpp","windows-build-java" ]
  build_nodes.each do |name|
    config.vm.define name do |windows|
      windows.vm.box = "sunflower"
      windows.vm.box_url = "file://vagrant-config/windows.json"
      windows.vm.box_check_update = true
      windows.vm.guest = :windows
      windows.vm.communicator = :winrm
      windows.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true
      windows.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true
      config.ssh.guest_port = 22
      windows.vm.base_mac = "080027E4791D"
      windows.vm.provision "artifactory-dns", type: "shell", inline: <<-SHELL
        bash -c "cat /cygdrive/c/vagrant/vagrant-config/artifactory_host.txt >> /cygdrive/c/Windows/System32/drivers/etc/hosts"
      SHELL
      if name == "windows-build-cpp"
        windows.vm.provision "build-cpp", type: "shell", path: "vagrant-windows-cpp-provision-build-all.bat"
        mem = 8192
        cpus = 4
        gui = false
      else
        mem = 4096
        cpus = 2
        gui = true
      end
      windows.vm.synced_folder synced_folder, "/cygdrive/c/vagrant_sync", type: "rsync",
        rsync__exclude: [ ".git/", "sunflower-*/", "delta-packs/", "*.box" ],
        rsync__args: ["--verbose", "--archive", "--delete", "-z", "--copy-links", "--progress"]
      windows.vm.synced_folder ".", "/vagrant"
      windows.vm.provider "virtualbox" do |v|
        v.memory = mem
        v.cpus = cpus
        v.name = "Sunflower " + name
        v.gui = gui
        v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
        v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
        v.customize ["modifyvm", :id, "--nictype1", "82540EM"]
      end
    end
  end

and this is the relevant error from the log:

==> windows-build: Rsyncing folder: /Users/jklo/projects/RAVE/source/sunflower-native/build/trunk.windows/ => /cygdrive/c/vagrant_sync
==> windows-build:   - Exclude: [".vagrant/", ".git/", "sunflower-*/", "delta-packs/", "*.box"]
Password:
Password:
Password:
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.
Host path: /Users/jklo/projects/RAVE/source/sunflower-native/build/trunk.windows/
Guest path: /cygdrive/c/vagrant_sync
Command: rsync --verbose --archive --delete -z --copy-links --progress --no-owner --no-group -e ssh -p 22 -o StrictHostKeyChecking=no -o IdentitiesOnly=true -o UserKnownHostsFile=/dev/null -i '/Volumes/Passport/vagrant.d/insecure_private_key' --exclude .vagrant/ --exclude .git/ --exclude sunflower-*/ --exclude delta-packs/ --exclude *.box /Users/jklo/projects/RAVE/source/sunflower-native/build/trunk.windows/ vag...@127.0.0.1:/cygdrive/c/vagrant_sync
Error: Warning: Permanently added '127.0.0.1' (RSA) to the list of known hosts.
Permission denied (publickey,keyboard-interactive).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-45/rsync/io.c(453) [sender=2.6.9]

Any thoughts on how I should correct?  I can tell the problem is related to port mapping, but not sure how to hint the synced_folder config to use the right one even if I setup a forward.

Thanks in advance for any help.

- Jim

Joaquin Menchaca

unread,
May 3, 2016, 12:54:52 AM5/3/16
to Vagrant
Maybe try rsync under MSYS2, and run vagrant from them.  I went with them because they were 64-bit.  Never had issues with rsync using MSYS2.  Milleage varied with cygwin.

Thomas Messier

unread,
Oct 20, 2016, 9:27:47 PM10/20/16
to Vagrant
Did you ever figure out how to fix this? I'm wrestling with this same issue and have wasted way too many hours already.
Reply all
Reply to author
Forward
0 new messages