How to fix authentication failure issue in customized Vagrant box

from: https://github.com/mitchellh/vagrant/issues/5186

The failure reason:

vagrant ssh-config on the base provisioned box(hashicorp/precise32) loads the identity file from .vagrant directory of the project

But the packaged box that is failing loads it from/Users/{username}/.vagrant.d/insecure_private_key

The source box use the insecure key
by default the actual version of vagrant will remove it, to make it secure
the new box, use a generated pair key.. that is not being used anymore
vagrant can’t connect to the new box.

Solution:

wget https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub -O .ssh/authorized_keys
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
chown -R vagrant:vagrant .ssh

Then when building the base box I think you need to add the config.ssh.insert_key = false to your Vagrantfile. If you built a new version of the box you can simply do a vagrant box update otherwise you can remove and re-add the box to get the newest box.

(You may need to add config.ssh.insert_key = false in the new Vagrantfile of the customized box generated from the base box)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s