Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Fix Vagrant's Authentication failure after re-building the box
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2202
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
$ vagrant ssh-config
Host default
HostName 127.0.0.1
User vagrant
Port 2202
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /home/ten0s/.vagrant.d/boxes/ten0s-VAGRANTSLASH-centos6.5_x86_64/0/virtualbox/vagrant_private_key
IdentitiesOnly yes
LogLevel FATAL
# generate public key out of new private (-y key)
$ ssh-keygen -y -f /home/ten0s/.vagrant.d/boxes/ten0s-VAGRANTSLASH-centos6.5_x86_64/0/virtualbox/vagrant_private_key > /home/ten0s/.vagrant.d/boxes/ten0s-VAGRANTSLASH-centos6.5_x86_64/0/virtualbox/vagrant_private_key.pub
# copy new identity. will ask for vagran't password, which is `vagrant'
$ ssh-copy-id -i /home/ten0s/.vagrant.d/boxes/ten0s-VAGRANTSLASH-centos6.5_x86_64/0/virtualbox/vagrant_private_key -p 2202 vagrant@127.0.0.1

You are a lifesaver, that works buddy. Do you know why we have to fix it in the first place?

(This is still a mistery to me, sometimes I package a box, add it, and when I 'vagrant up', I'm asked for the password. YOUR fix works and we can then repackage properly which is awesome.)

Thank you buddy

On cygwin.

$ vagrant ssh-config
Host default
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile C:/Users/Administrator/.vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL

$ ssh-keygen -f C:/Users/Administrator/.vagrant.d/insecure_private_key

$ ssh-copy-id -i C:/Users/Administrator/.vagrant.d/insecure_private_key -p 2222 vagrant@127.0.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment