benedict_w
benedict_w

Reputation: 3598

Vagrant SSH Permissions

I am new to Vagrant and get the following error on vagrant up or vagrant ssh:

The private key to connect to this box via SSH has invalid permissions
set on it. The permissions of the private key should be set to 0600, otherwise SSH will
ignore the key. Vagrant tried to do this automatically for you but failed. Please set the
permissions on the following file to 0600 and then try running this command again:

[...]/.vagrant/machines/default/virtualbox/private_key

I have run:

$ sudo chmod 666 [...]/.vagrant/machines/default/virtualbox/private_key

I also tried (600, 777) but still get the same error.

Please can someone tell me what is wrong and how to fix it?

Upvotes: 15

Views: 10371

Answers (5)

Nick F
Nick F

Reputation: 10102

If you're using the Windows Subsystem for Linux (WSL), this error can occur when you're trying to vagrant up in a directory that is outside the user's home directory.

From the Vagrant docs:

If a Vagrant project directory is not within the user's home directory on the Windows system, certain actions that include permission checks may fail (like vagrant ssh). When accessing Vagrant projects outside the WSL Vagrant will skip these permission checks when the project path is within the path defined in the VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH environment variable.

Changing the VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH to the current working directory (or a directory above it) can fix this. For example, if your project is in /mnt/c/www, then set the environment variable accordingly:

export VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH="/mnt/c/www"

Upvotes: 9

Antonio Isas
Antonio Isas

Reputation: 31

I had this same problem and turns out chmod seems to be working fine but is not actually changing permissions, my files where at an NTFS partition, try changing them to an ext4 or similar.

Upvotes: 2

Flavio
Flavio

Reputation: 41

I got the same error now. The problem happened because i was trying to do vagrant up in an NTFS partition, just like the error message tell me. So i created an directory link in my ext4 partition and an simbloc link in my NTFS to solve this. Works Fine now!

Thanks!

Upvotes: 4

Tyler
Tyler

Reputation: 16

Got this error using otto (which layers on vagrant) It is def filesystem related, have a fat partition to allow use with windows (used to, no longer). When the permissions couldn't be set on the partition I just copied the whole directory over to my user directory (as I always should have).

Was using git so I just reset to head to get back to my starting place... re-ran: otto compile otto dev up and running now.

Upvotes: 0

rubens21
rubens21

Reputation: 801

I just had this issue, and I worked around it moving the private_key file to another place, changing its permission, and then creating a symbolic link at the original place. So,

$ mv [...]/.vagrant/machines/default/virtualbox/private_key /some/path/where/you/can/change/permissions
$ ln -s /some/path/where/you/can/change/permissions [...]/.vagrant/machines/default/virtualbox/private_key 

Upvotes: 26

Related Questions