Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing Vagrantfile causes "vagrant ssh" to prompt for a password?

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?

like image 400
Tommy Avatar asked May 12 '14 00:05

Tommy


People also ask

What is vagrant SSH password?

According to the Vagrant documentation, there is usually a default password for the user vagrant which is vagrant .

How do I turn off vagrant SSH?

Terminate the SSH session with CTRL+D , or by logging out. vagrant@vagrant:~$ logout Connection to 127.0. 0.1 closed.

What is vagrant root password?

Root Password: "vagrant"


1 Answers

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

like image 116
cOp Avatar answered Oct 02 '22 02:10

cOp