mrdavidlaing / vagrant-unison

Vagrant plugin to sync local files to VM using Unison over SSH
MIT License
37 stars 29 forks source link

Error: Warning: Identity file ["~/.vagrant.d/insecure_private_key"] not accessible: No such file or directory. #6

Open djdevin opened 10 years ago

djdevin commented 10 years ago

When I try to do a vagrant sync it can't seem to read my vagrant SSH key to do the sync. vagrant ssh works as expected. Unison pops up, but asks for a password. The "insecure_private_key" file does exist.

Full output:

Unisoning changes from {host}::/home/devin/Websites/host_folder/ --> {guest VM}::guest_folder/
There was an error when attemping to sync folders using unison.
Please inspect the error message below for more info.

Host path: /home/devin/Websites/host_folder/
Guest path: guest_folder/
Error: Warning: Identity file ["/home/devin/.vagrant.d/insecure_private_key"] not accessible: No such file or directory.
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

Full command causing error: 
["unison", "-batch", "-ignore=Name {.git*,.vagrant/,*.DS_Store}", "-sshargs", "-p 2222 -o StrictHostKeyChecking=no -i [\"/home/devin/.vagrant.d/insecure_private_key\"]", "/home/devin/Websites/host_folder/", "ssh://vagrant@127.0.0.1/guest_folder/"]

Vagrantfile:

Vagrant.require_plugin "vagrant-unison"
Vagrant.configure("2") do |config|
  config.vm.box = "dlc"
  config.vm.box_url = "http://redacted"
  config.vm.network "forwarded_port", guest: 80, host: 8080
  config.vm.network "forwarded_port", guest: 443, host: 8443
  config.vm.network "forwarded_port", guest: 3306, host: 3307
  config.sync.host_folder = "host_folder/"
  config.sync.guest_folder = "guest_folder/"
end
falschparker82 commented 10 years ago

same one here - looks like ssh_info[:private_key_file] is an array instead of a string...

ieb-jim commented 10 years ago

Also getting this. Getting an array instead of a string.

edtoon commented 10 years ago

I believe this is fixed in master but the gem hasn't been updated since version.. 4? It's at 9 now - just copy the files from github over the plugin in your vagrant install and it should work fine.

krisdante commented 10 years ago

No it is not fixed. I copied clone and still same issue.

etikka commented 9 years ago

I had the same problem in version 9 that the private_key string was in an array.

A quick dirty fix which worked for me was to edit the command.rb file:

Add after the line: ssh_info = machine.ssh_info this line: keypath = ssh_info[:private_key_path].first

Then change the line "-sshargs", "-p #{ssh_info[:port]} -o StrictHostKeyChecking=no -i #{ssh_info[:private_key_path]}", to "-sshargs", "-p #{ssh_info[:port]} -o StrictHostKeyChecking=no -i #{keypath}",

So the result is:

        ssh_info = machine.ssh_info
        keypath = ssh_info[:private_key_path].first

        # Create the guest path
        machine.communicate.sudo("mkdir -p '#{guestpath}'")
        machine.communicate.sudo("chown #{ssh_info[:username]} '#{guestpath}'")

        # Unison over to the guest path using the SSH info
        command = [
          "unison", "-batch",
          "-ignore=Name {.git*,.vagrant/,*.DS_Store}",          
          "-sshargs", "-p #{ssh_info[:port]} -o StrictHostKeyChecking=no -i #{keypath}",
          hostpath,
          "ssh://#{ssh_info[:username]}@#{ssh_info[:host]}/#{guestpath}"
         ]

This will probably break something for some folks, so consider yourself warned. Hope it helps someone who is wrestling with the problem.

dcosson commented 8 years ago

I still get this error on 0.0.4.

EDIT: I see now that this is a very old version. I'll open a new issue with not being able to install anything newer than 0.0.4