Changing Vagrantfile causes “vagrant ssh” to prompt for a password?

久未见 提交于 2019-12-29 04:37:15

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/23599297/changing-vagrantfile-causes-vagrant-ssh-to-prompt-for-a-password

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!