Vagrant: Warning: Authentication failure. Retrying - vagrant Ruby

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
Asked Nov 08 '21 09:11
avatar intelligence
intelligence

4 Answer:

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 'authorizedkeys' file must be 'rw' only for 'vagrant' user so "chmod 600 authorizedkeys"; 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.

1
Answered Jan 26 '15 at 16:23
avatar  of ruskotron
ruskotron

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

at Vagrantfile:

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

config.vm.network :forwardedport, guest: 7050, host: 7050 # fabric orderer service config.vm.network :forwardedport, guest: 7051, host: 7051 # fabric peer service config.vm.network :forwardedport, guest: 7053, host: 7053 # fabric peer event service config.vm.network :forwardedport, 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.

1
Answered May 26 '17 at 15:37
avatar  of yaom2018
yaom2018

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.

1
Answered Feb 23 '15 at 03:18
avatar  of jiasir
jiasir

However this plugin seemed to solve the problem!

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

1
Answered Jan 19 '15 at 21:44
avatar  of ux-engineer
ux-engineer