Reputation: 532
I see a lot of people are getting this error but none apparently for the same reasons as me. An explanation for the reason in my case would be useful.
After adding this to my vagrant file:
config.vm.synced_folder "./home", "/home/vagrant"
I got the following error when using vagrant ssh
:
[email protected]: Permission denied (publickey)
When I removed the synced_folder line the error no longer shows and vagrant ssh
works fine.
What's happening and why can't I do this?
Upvotes: 0
Views: 2427
Reputation: 649
A HACK:
You could also create .ssh/authorized_keys
in host machine first.
Then run vagrant ssh-config
to get the location of your private key.
Then run ssh-keygen -y -f ${your private key}
to get your public key.
Finally, copy the content into host machine .ssh/authorized_keys
. Don't forget to append vagrant
.
Upvotes: 0
Reputation: 344
When you configure the guest to have a synced folder at /home/vagrant
, it overwrites the entire folder with the contents of your synced folder. Vagrant places its key in the ~/.ssh/authorized_keys
file, which allows it to ssh into the guest.
My personal set-up is as follows:
config.vm.synced_folder "./code", "/home/vagrant/code"
This way you create a new directory in your root directory without overwriting the ssh keys file.
Hope this helps, best regards.
Upvotes: 1