Skip to content

Instantly share code, notes, and snippets.

@ten0s
Created June 1, 2015 10:21
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ten0s/f6b4f598a46344ab0dfd to your computer and use it in GitHub Desktop.
Save ten0s/f6b4f598a46344ab0dfd to your computer and use it in GitHub Desktop.
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
Copy link

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
Copy link

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
Copy link

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