Skip to content

Instantly share code, notes, and snippets.

Embed
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
@Sydney-o9

This comment has been minimized.

Copy link

Sydney-o9 commented Aug 20, 2015

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

@ezhiznevskiy

This comment has been minimized.

Copy link

ezhiznevskiy commented Nov 18, 2015

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

@Lorenz25

This comment has been minimized.

Copy link

Lorenz25 commented Jan 11, 2018

Hi, I'm totally new to this. Hope this is the solution to the authentication failure I'm getting.
Tried this, but the "ssh-keygen -y -f" is asking for a passphrase, which I do not know.
Can anyone elaborate on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.