How to fix Vagrant error: `private_key_path` file must exist:

Mr B picture Mr B · Apr 16, 2015 · Viewed 9.7k times · Source

I've been using PuPHPet to create virtual development environments.

Yesterday I generated a config file for a new box. When I try to spin it up using the vagrant up command, I get the following error message:

C:\xx>vagrant up

Bringing machine 'default' up with 'virtualbox' provider... There are errors in the configuration of this machine. Please fix the following errors and try again:

SSH: * private_key_path file must exist: P://.vagrant.d/insecure_private_key

I came across this question and moved the insecure_private_key from puphpet\files\dot\ssh to the same directory as where the Vagrantfile is. However this gives the same error.

I'm also confused by the directory given in the error message;

P://.vagrant.d/insecure_private_key

Why is the 'P' drive mentioned?

My Vagrantfile can be found here.

Appreciate any advice on solving this error.

Answer

Mr B picture Mr B · Jun 4, 2015

I fixed the problem by replacing the path to insecure_private_key by hard coding the path to the insecure_private_key file.

So it went from:

config.ssh.private_key_path = [
    customKey,
    "#{ENV['HOME']}/.vagrant.d/insecure_private_key"
]

To:

config.ssh.private_key_path = [
    customKey,
    "C:/Users/My.User/.vagrant.d/insecure_private_key"
]