Vagrant: Vagrant: Warning: Authentication failure. Retrying

Created on 17 Nov 2014  Â·  13Comments  Â·  Source: hashicorp/vagrant

Trying to get going with a new vagrant project. When running vagrant up I’m faced with default: Warning: Authentication failure. Retrying…(entire log here: http://pastie.org/private/vkzeyoyq79t9wqnh3dnmq)

This error doesn’t seem all that uncommon, but I’ve tested all solutions I could come a cross and haven’t been able to get it to work yet.

If I run vagrant up with gui enabled I get to the login screen just fine and I’m able to login.
If I run ssh -p 2222 vagrant@localhost after fail message I get in just fine.
I've tested moving key from id_rsa into /Users/myuser/.vagrant.d/insecure_private_key
I’ve tried adding: config.ssh.private_key_path = "~/.ssh/id_rsa" and config.ssh.forward_agent = true to the Vagrantfile, with no luck.
There's no other boxes running but this one. I do however have an older box with precise32 and that one I can get into..

Virtualbox version: 4.3.18r96516
Vagrant version: 1.6.5
OS: OSX 10.9.5

vagrant ssh-config

  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /Users/myuser/.vagrant.d/insecure_private_key
  IdentitiesOnly yes
  LogLevel FATAL

Tested boxes:
Bedrock (Custom Trusty64)
Trusty64
Trusty32

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.require_version '>= 1.5.1'

Vagrant.configure('2') do |config|
  config.vm.box = 'roots/bedrock'

    #config.vm.provider :virtualbox do |vb|
     # vb.gui = true
    #end

  # Required for NFS to work, pick any local IP
  config.vm.network :private_network, ip: '192.168.50.5'
  config.vm.hostname = 'example.dev'

  if !Vagrant.has_plugin? 'vagrant-hostsupdater'
    puts 'vagrant-hostsupdater missing, please install the plugin:'
    puts 'vagrant plugin install vagrant-hostsupdater'
  else
    # If you have multiple sites/hosts on a single VM
    # uncomment and add them here
    #config.hostsupdater.aliases = %w(site2.dev)
  end

  # Define path to bedrock directory on your local host machine
  #   - relative to Vagrantfile
  #   - use forward slashes ("/") regardless of your OS
  bedrock_path = '../bedrock'

  # Sync bedrock directory
  bedrock_path_server = File.join('/srv/www', File.basename(bedrock_path), 'current')

  if Vagrant::Util::Platform.windows?
    config.vm.synced_folder bedrock_path, bedrock_path_server, owner: 'vagrant', group: 'www-data', mount_options: ['dmode=776', 'fmode=775']
  else
    if !Vagrant.has_plugin? 'vagrant-bindfs'
      raise Vagrant::Errors::VagrantError.new,
        "vagrant-bindfs missing, please install the plugin:\nvagrant plugin install vagrant-bindfs"
    else
      config.vm.synced_folder bedrock_path, '/vagrant-nfs', type: 'nfs'
      config.bindfs.bind_folder '/vagrant-nfs', bedrock_path_server, u: 'vagrant', g: 'www-data'
    end
  end

  config.vm.provision :ansible do |ansible|
    # adjust paths relative to Vagrantfile
    ansible.playbook = './site.yml'
    ansible.groups = {
      'web' => ['default'],
      'development' => ['default']
    }
    ansible.extra_vars = {
      ansible_ssh_user: 'vagrant',
      user: 'vagrant'
    }
    ansible.sudo = true
  end


  config.vm.provider 'virtualbox' do |vb|
    # Give VM access to all cpu cores on the host
    cpus = case RbConfig::CONFIG['host_os']
      when /darwin/ then `sysctl -n hw.ncpu`.to_i
      when /linux/ then `nproc`.to_i
      else 2
    end

    # Customize memory in MB
    vb.customize ['modifyvm', :id, '--memory', 1024]
    vb.customize ['modifyvm', :id, '--cpus', cpus]

    # Fix for slow external network connections
    vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']
    vb.customize ['modifyvm', :id, '--natdnsproxy1', 'on']
  end
end

Most helpful comment

for me, this was resolved by changing the permissions on .ssh folder in vagrant home directort (i.e. "~vagrant/.ssh"). I think I messed up the permissions when I was setting up ssh keys for my application.

It seems that 'authorized_keys' file must be 'rw' only for 'vagrant' user so "chmod 600 authorized_keys"; the same goes for the directory itself and its parent:

so:

chmod 600 authorized_keys
chmod 700 .
chmod 700 ..

It was only after I had _all_ these permissions restored that vagrant ssh started to work again.

I think it's something to do with ssh security. It refuses to recognise certificates if they are any way accessible beyond the current user, so vagrants attempts to login are thus rejected.

All 13 comments

It isn't an error, it is a warning (as it says), and it will retry (as it says). Does it then never complete successfully? If it doesn't complete successfully after a few minutes, please post via gist the debug log (run with --debug) and we can take a closer look. Thanks!

I'm having exactly same problem. Nothing seems to work. I havent tried precise32 as I need to get CentOS running. Now trying chef/centos-6.5.

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'chef/centos-6.5' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'chef/centos-6.5'
default: URL: https://atlas.hashicorp.com/chef/centos-6.5
==> default: Adding box 'chef/centos-6.5' (v1.0.0) for provider: virtualbox
default: Downloading: https://atlas.hashicorp.com/chef/boxes/centos-6.5/versions/1.0.0/providers/virtualbox.box
==> default: Successfully added box 'chef/centos-6.5' (v1.0.0) for 'virtualbox'!
==> default: Importing base box 'chef/centos-6.5'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'chef/centos-6.5' is up to date...
==> default: Setting the name of the VM: asuntolaskuri_default_1421702130124_87892
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 80 => 8080 (adapter 1)
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

    If you look above, you should be able to see the error(s) that
    Vagrant had when attempting to connect to the machine. These errors
    are usually good hints as to what may be wrong.

    If you're using a custom box, make sure that networking is properly
    working and you're able to connect to the machine. It is a common
    problem that networking isn't setup properly in these boxes.
    Verify that authentication configurations are also setup properly,
    as well.

    If the box appears to be booting properly, you may want to increase
    the timeout ("config.vm.boot_timeout") value.

Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
    config.vm.box = "chef/centos-6.5"
    #config.vm.network "public_network", ip: "192.168.1.34"
    config.vm.network :forwarded_port, guest: 80, host: 8080
    config.vm.synced_folder ".", "/home", :mount_options => ["dmode=777", "fmode=666"]
    config.vm.provision :shell, :path => "vagrant/install.sh"
    config.vm.provision :shell, run: "always", :path => "vagrant/load.sh"
    #config.ssh.private_key_path = "~/.ssh/id_rsa"
    #config.ssh.forward_agent = true
end

However this plugin seemed to solve the problem!

https://github.com/virtuald/vagrant-rekey-ssh

I'm having the same problem. It seems to happen after I vagrant halt {id} the VMs and then started it with vagrant up.

Steps:
0- Host machine is OSX
1- Clone this repo https://github.com/bubenkoff/vagrant-docker-example/
2- vagrant up
3- Used vagrant global-status & vagrant halt image-id
4- vagrant up again
But I don't know, by now I've messed around so much with my host machine that I'm not sure what's the cause, I have also have boot2docker installed on my host.

for me, this was resolved by changing the permissions on .ssh folder in vagrant home directort (i.e. "~vagrant/.ssh"). I think I messed up the permissions when I was setting up ssh keys for my application.

It seems that 'authorized_keys' file must be 'rw' only for 'vagrant' user so "chmod 600 authorized_keys"; the same goes for the directory itself and its parent:

so:

chmod 600 authorized_keys
chmod 700 .
chmod 700 ..

It was only after I had _all_ these permissions restored that vagrant ssh started to work again.

I think it's something to do with ssh security. It refuses to recognise certificates if they are any way accessible beyond the current user, so vagrants attempts to login are thus rejected.

Had this issue today, while trying to use the Docker provider.

Here's how I fixed it:

The current version of Vagrant creates a ~/.vagrant.d directory. Within that directory I found several lock files. I deleted those. Then I opened VirtualBox and shutdown and removed the "docker-host-*" VM.

After doing that I was able to successfully do 'vagrant up --provider=docker'.

I am having the same problem, I solved it by:
changing the config.ssh.private_key_path setting to /User/Taio/.vagrant.d/insecure_private_key.
And finally it worked.

I used envision's solution, above, which worked.

My laptop battery got empty while vagrant was running and may have corrupted my key on the guest machine. (I think it was a guest issue because vagrant status said VM is running but i could not SSH in = various authentication errors, although i could log in via Virtualbox GUI)

envision's solution fixed the issue for me.

@oborerichard great to hear you got your issue solved! Actually the problem that I had is explained in detail here: https://stackoverflow.com/questions/32520921/vagrant-1-7-ssh-authentication-failure-on-osx-private-key-not-copied-to-vm

you can add follow code
[ config.ssh.username = "vagrant"
config.ssh.password = "vagrant"]

at Vagrantfile:

Vagrant.require_version ">= 1.7.4"
Vagrant.configure('2') do |config|
config.vm.box = "hyperledger/fabric-baseimage"
config.vm.box_version = ENV['USE_LOCAL_BASEIMAGE'] ? "0": baseimage_release # Vagrant does not support versioning local images, the local version is always implicitly version 0

config.vm.network :forwarded_port, guest: 7050, host: 7050 # fabric orderer service
config.vm.network :forwarded_port, guest: 7051, host: 7051 # fabric peer service
config.vm.network :forwarded_port, guest: 7053, host: 7053 # fabric peer event service
config.vm.network :forwarded_port, guest: 7054, host: 7054 # fabric-ca service
config.vm.network :forwarded_port, guest: 5984, host: 15984 # CouchDB service

  config.ssh.username = "vagrant"
  config.ssh.password = "vagrant"

and revagrant up the Warning message will disappear.

I know this is potentially totally unrelated, but this is high in the Google results and I hope it helps someone. My auth error was a result of the following:

  1. I was trying to create a Vagrant base box with Packer.
  2. I was using another Vagrant box as the base for that.
  3. In order to extract the .ovf I used vagrant up and vagrant package --base {id}, then untarred the .box file.
    At which point, even though I didn't think about it, the SSH key had been replaced by default (whoops)!
    The solution was, in the Vagrantfile for the _original_ box:
Vagrant.configure("2") do |config|
  config.vm.box = "bento/ubuntu-16.04"
  config.ssh.insert_key = false
end

The insert_key = false line allowed me to retain the original (insecure) Vagrant key, and there was much rejoicing.

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hesco picture hesco  Â·  3Comments

RobertSwirsky picture RobertSwirsky  Â·  3Comments

mpontillo picture mpontillo  Â·  3Comments

OtezVikentiy picture OtezVikentiy  Â·  3Comments

tomhking picture tomhking  Â·  3Comments