Vagrant VM Fails to Boot

1

I have a Vagrant environment that requires me to forward port 80 so I bring it up under sudo on an OS X machine. This has always been fine until I recently upgraded to Vagrant 1.2.2. Now it fails to boot.

[default] Waiting for VM to boot. This can take a few minutes.
[default] Failed to connect to VM!
Failed to connect to VM via SSH. Please verify the VM successfully booted
by looking at the VirtualBox GUI.

Because I'm running under sudo, the machine never gets added to the Virtualbox GUI, but that's always been the case for this environment.

I don't get any indication that there was a problem with the additions -- a potential source of this error, from what I've read. I can bring things up just fine if I change to using port 8080 on the host machine. I can't use the app, but the VM itself loads up and provisions nicely.

As far as I can tell, the only thing that's changed is:

  1. I upgraded my Vagrant version
  2. I updated the project's Vagrantfile to use v2 syntax.

Anyone have any idea what I might be missing? I thought I'd be able to find this pretty easily, but it's quickly becoming a very real problem.

UPDATE 27 JUN

It appears that it's an SSH key issue if VAGRANT_LOG=DEBUG is to be believed:

DEBUG ssh: Checking key permissions: /Users/robwilkerson/.vagrant.d/insecure_private_key
 INFO ssh: SSH not up: #<Vagrant::Errors::SSHKeyBadOwner: 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:

/Users/robwilkerson/.vagrant.d/insecure_private_key>
 INFO subprocess: Starting process: ["VBoxManage", "showvminfo", "3422bba7-8f35-42ad-ba1a-c127c6cb3cf6", "--machinereadable"]

I assume it wants a key owned by root since I'm under sudo, but if that's the case, why isn't it looking at root's ~/.vagrant.d/? Did v2 get more strict about this? I was able to sudo vagrant up just fine until the upgrade. Since this is my only dev environment that requires sudo to up, I'd rather not change key ownership. Is there another way?

Lots of questions, I know, but I could really use a hand understanding/fixing this one.

Rob Wilkerson

Posted 2013-06-26T16:20:42.057

Reputation: 353

Answers

2

I haven't found a better solution to this than to toggle the owner of the private key when switching between this project and others. To make it suck just a little less, I created a zsh function:

vkey() { sudo chown "$*":staff ~/.vagrant.d/insecure_private_key; }

From the command line, I can update the key owner with this:

$ vkey <new_owner_username>

Rob Wilkerson

Posted 2013-06-26T16:20:42.057

Reputation: 353

2

Try changing the ownership of the vagrant.d directory:

# cd ~
# sudo chown -R root .vagrant.d/

Jean Valjean

Posted 2013-06-26T16:20:42.057

Reputation: 31

It will only worse the situation: Vagrant will fail with The home directory you specified is not accessible. The home directory that Vagrant uses must be both readable and writable. – om-nom-nom – 2014-09-09T12:05:04.907

If you need to run vagrant as root (to bind to host port 80), this fix works. – Dan Kohn – 2015-06-06T12:31:03.697