Private key to connect to the machine via SSH must be owned by the user running Vagrant

Viewed 4562

I am trying to follow this vagrant tutorial. I get error after my first two command. I wrote these two command from command line

$ vagrant init hashicorp/precise64
$ vagrant up

After I ran vagrant up command I get this message.

The private key to connect to the machine via SSH must be owned
by the user running Vagrant. This is a strict requirement from
SSH itself. Please fix the following key to be owned by the user
running Vagrant:

/media/bcc/Other/Linux/vagrant3/.vagrant/machines/default/virtualbox/private_key

And then if I run any command I get the same error. Even if I run vagrant ssh I get the same error message. Please help me to fix the problem.

I am on linux mint and using virutal box as well.

3 Answers

Jakuje has the correct answer - if the file system you are working on supports changing the owner.

If you are trying to mount the vagrant box off of NTFS, it is not possible to change the owner of the key file.

If you want to mount the file on NTFS and you are running a local instance you can try the following which worked for me:

Vagrant Halt

[remove the vagrant box]

[Add the following line to Vagrantfile]

config.ssh.insert_key=false

[** you may need to remove and clone your project again]

Vagrant Provision

This solution may not be suitable for a live instance - it uses the default insecure ssh key. If you require more security you might be able to find a more palatable soultion here https://www.vagrantup.com/docs/vagrantfile/ssh_settings.html

If you put vagrant data on NTFS you can use this trick to bypass the keyfile ownership/permissions check.

Copy your key file to $HOME/.ssh/ or where-ever on a suitable filesystem where you can set it to the correct ownership and permissions. Then simply create a symlink (!) to it inside the NTFS directory (where you have set $VAGRANT_HOME, for example) like this:

ln -sr $HOME/.ssh/your_key_file your_key_file
Related