Vagrant: Vagrant fails to ssh to the ubuntu/xenial64 (asks for password) when env vars are used in Vagrantfile

Created on 4 Sep 2016  ·  9Comments  ·  Source: hashicorp/vagrant

Vagrant version

1.8.4

Host operating system

Arch Linux

Guest operating system

ubuntu/xenial64 box

Vagrantfile

Vagrant.configure('2') do |config|
  if ENV['B'] == 'ubuntu'
    config.vm.box = 'ubuntu/xenial64'
  else
    config.vm.box = 'centos/7'
  end
end

Debug output

https://gist.github.com/x-yuri/ef4dd24dbf72a2e5ffa0f28bbd46c9d0~~
https://gist.github.com/x-yuri/4bbcf7cf8c37746627409e34f00ea2e1

Expected behavior

It shouldn't ask for password when doing vagrant ssh.

Actual behavior

It asks for password.

Steps to reproduce

  1. B=ubuntu vagrant up
  2. vagrant ssh

    References

This issue is related, but seems to be a separate one. The one I'm describing here looks like an issue with vagrant. With the following Vagrantfile it works:

Vagrant.configure('2') do |config|
  config.vm.box = 'ubuntu/xenial64'
end

If you have a workaround in mind, you're welcome.

More info

If you make ubuntu default box:

Vagrant.configure('2') do |config|
  if ENV['B'] == 'centos'
    config.vm.box = 'centos/7'
  else
    config.vm.box = 'ubuntu/xenial64'
  end
end

And do vagrant up && vagrant ssh, it logs in. So, it seems like something is grepping Vagrantfile and takes the last occurrence. Or the environment variable gets lost somewhere along the way.

bug guesubuntu needs-repro

Most helpful comment

the same issue, happens to me.

Host operating system: macOS Sierra
Guest operating system: ubuntu/xenial64 box
Vagrant version: 1.8.6
Virtualbox version: 5.0.26 r108824

All 9 comments

Same for me (on macOS). vagrant up always ask for password.

👍 happens here as well. MacOS

Happens to me, also.

Host operating system: Xubuntu 16.04
Guest operating system: ubuntu/xenial64 box
Vagrant version: 1.8.6
Virtualbox version: 5.0.26 r108824

the same issue, happens to me.

Host operating system: macOS Sierra
Guest operating system: ubuntu/xenial64 box
Vagrant version: 1.8.6
Virtualbox version: 5.0.26 r108824

Affects me, too.

Host operating system: Sabayon Linux
Guest operating system: ubuntu/xenial64 (box_version = "20161022.0.0")
Vagrant version: 1.8.5
Virtualbox version: 5.1.6 r110634

+1

Same for me. I think this it the bug, so this issue should be closed here: https://bugs.launchpad.net/cloud-images/+bug/1569237

Host operating system: Ubuntu
Guest operating system: ubuntu/xenial64 (box_version = "20170118.1.0")
Vagrant version: 1.9.1
Virtualbox version: 5.1.14r112924

Closing this as an upstream issue with box author. Cheers!

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

luispabon picture luispabon  ·  3Comments

RobertSwirsky picture RobertSwirsky  ·  3Comments

mpontillo picture mpontillo  ·  3Comments

janw-me picture janw-me  ·  3Comments

Cbeck527 picture Cbeck527  ·  3Comments