Vagrant: SSH Authentication failure when doing 'vagrant up'

Created on 8 Sep 2016  ยท  5Comments  ยท  Source: hashicorp/vagrant

Vagrant version

Vagrant 1.8.5

Host operating system

OSX El Capitan 10.11.6

Guest operating system

CentOS 7.1

Vagrantfile

VAGRANTFILE_API_VERSION = '2'

Vagrant.require_version '>= 1.5.0'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.hostname = 'my-vm'
  config.vm.box = 'opscode-centos-7.1'
  config.vm.box_url = "https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.1_chef-provisionerless.box"
  config.vm.box_check_update = "true"
  config.vm.boot_timeout = 600

  if Vagrant.has_plugin?("vagrant-vbguest")
    config.vbguest.auto_update = false
    config.vbguest.no_install = true
  end

  config.berkshelf.enabled = false if Vagrant.has_plugin?("vagrant-berkshelf")

  config.vm.provider :virtualbox do |p|
    p.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
    p.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    p.customize ["modifyvm", :id, "--memory", "4096"]
    p.customize ["modifyvm", :id, "--cpus", "2"]
    p.customize ["modifyvm", :id, "--vram", "32"]
  end
end

Debug output

https://gist.github.com/rishabhtulsian/770970e80fa2f556af98b7a140345448

Expected behavior

Vagrant should have connected to the VM and provisioned it.

Actual behavior

Vagrant kept retrying and authentication failed.

Steps to reproduce

  1. Create VagrantFile
  2. Run vagrant up

    References

I did take a look at the existing bugs and the fixes/suggestions they provide. None of those worked for me. However I tried something different which fixed it, hence I am opening this issue.

I tried suggestions from these issues

  • GH-7732
  • GH-7610 (The fix suggested here was in the public_key.rb file on my machine)

Workaround

This workaround worked for me config.ssh.insert_key = false

Fix

I changed all the chmod 0700 ~/.ssh to chmod 0600 ~/.ssh

Most helpful comment

If this is a self-made box and you do not use config.ssh.insert_key = false, make sure that you delete private key before you package the box!

rm .vagrant/machines/default/virtualbox/private_key

You may need to replace default with the actual box name.

If you forget it, than this private key part gets packaged with the box and than you have auth failures when you try to use the imported box. Vagrant will not try to use insecure key and will not regenerate the key for the new instance based on this box.

I discovered it after 3 hours of fighting the problem...

All 5 comments

Modify /opt/vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/guests/linux/cap/public_key.rb

on line 57 insert chmod 0600 ~/.ssh/authorized_keys

This issue has been fixed in 1.8.6

Thanks that worked!

You're welcome, I struggled with that one for a few days as well, its buried in the comment section of one of the tickets you linked. Glad I could help you, my first contribution to github!

If this is a self-made box and you do not use config.ssh.insert_key = false, make sure that you delete private key before you package the box!

rm .vagrant/machines/default/virtualbox/private_key

You may need to replace default with the actual box name.

If you forget it, than this private key part gets packaged with the box and than you have auth failures when you try to use the imported box. Vagrant will not try to use insecure key and will not regenerate the key for the new instance based on this box.

I discovered it after 3 hours of fighting the problem...

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

mpontillo picture mpontillo  ยท  3Comments

dorinlazar picture dorinlazar  ยท  3Comments

janw-me picture janw-me  ยท  3Comments

StefanScherer picture StefanScherer  ยท  3Comments

jsirex picture jsirex  ยท  3Comments