Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 497
benedict_w Avatar asked Dec 28 '14 14:12

benedict_w


4 Answers

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 
like image 95
rubens21 Avatar answered Nov 05 '22 04:11

rubens21


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"
like image 30
Nick F Avatar answered Nov 05 '22 03:11

Nick F


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!

like image 4
Flavio Avatar answered Nov 05 '22 04:11

Flavio


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.

like image 2
Antonio Isas Avatar answered Nov 05 '22 03:11

Antonio Isas