Solution – vagrant Warning: Authentication failure. Retrying…

I recently ran into this error after generating a new set of SSH keys in my Vagrant machine. I looked around couldn’t find any concrete solution which is why I decided to make this post so that it might end up helping you.

Vagrant SSH – vagrant Warning: Authentication failure. Retrying…

This usually happens when you make any change to ~/.ssh  directory in your vagrant machine or you generate a new key. A “good to know” tip is that Vagrant stores the private key in “/home/USER/Documents/boxes/.vagrant/machines/your-machine/virtualbox” , where “USER/Documents/boxes” is assumed to be the location for your vagrant setup. Rest of the path remains the same. You would find a vagrant key at “./.vagrant/machines/your-machine/virtualbox/private_key”  where “your-machine” is the name of your Vagrant machine. Now you can simply modify your Vagrant file to use this particular key to log you in instead of the new key that you might have generated / setup.

Here’s how you do it – 

my-machine.ssh.private_key_path = "/home/USER/Documents/boxes/.vagrant/machines/my-machine/virtualbox/private_key"

Again, remember to replace /home/USER/Documents/boxes with the path of your Vagrantfile (Vagrant setup). So now your Vagrantfile should look like this with updated private keys.

Vagrant.configure("2") do |config|
  config.vm.define "jenkins" do |jenkins| = "bento/ubuntu-16.04"
      jenkins.ssh.private_key_path = "/home/USER/Documents/boxes/.vagrant/machines/your-machine/virtualbox/private_key"
      jenkins.vm.hostname = "jenkins" "private_network", ip: ""

Feel free to comment below if your issue persists and I’d be happy to help you troubleshoot it further.

Published by Nishant

With over 9 years in the industry, initially started as a Linux administrator and transitioned into DevOps Engineer. I work with deployment and infrastructure automation as well as application release management processes.

Leave a comment

Your email address will not be published. Required fields are marked *

Hooman? *