Pergunta

I've been playing around with setting up an environment using Vagrant, and I'm having an issue with the vagrant ssh command.

When I change the path of the mounted share folder in the Vagrantfile, and do a vagrant reload, I'm no longer able to vagrant ssh without it asking me for a password.

This was my original configuration for a mounted share, which works:

config.vm.synced_folder "./", "/home/vagrant/shared"

This is what I was trying to change to and it doesn't work after vagrant reload (asks me for password):

config.vm.synced_folder "./", "/home/vagrant"

Everything else in the file remained unchanged. Any idea what's going on here?

Foi útil?

Solução

Take note of what is actually happening here. When you share the /home/vagrant folder the VM Provider (most likely VirtualBox) has control of that folder and the permissions get all mangled by VirtualBox. You won't be able to set the 0700 perms for the .ssh folder nor will you be able to set the 0600 perms for the authorized_keys file inside the .ssh folder. Consequently, the vagrant ssh command will explicitly ask you for the password since it can't check the public key in the .ssh folder.

Makio was right about /vagrant being the default share folder. You can share pretty much any folder you want except for the /home/vagrant folder. I know about this personally because I ran into the very same issue you did. By allowing Vagrant to control the /home/vagrant folder, the permissions get set appropriately for vagrant ssh to function properly.

Glad it's resolved and I hope I shed a bit more light on exactly why this gives people a problem.

c0p

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top