5

I made my custom vagrant box for CentOS 6.6. My question is why vagrant always requires password when I 'vagrant up' at only first time. Here is the console log:

$ vagrant up
Bringing machine 'ns' up with 'virtualbox' provider...
==> ns: Clearing any previously set forwarded ports...
==> ns: Clearing any previously set network interfaces...
==> ns: Preparing network interfaces based on configuration...
    ns: Adapter 1: nat
    ns: Adapter 2: hostonly
==> ns: Forwarding ports...
    ns: 22 => 2222 (adapter 1)
==> ns: Running 'pre-boot' VM customizations...
==> ns: Booting VM...
==> ns: Waiting for machine to boot. This may take a few minutes...
    ns: SSH address: 127.0.0.1:2222
    ns: SSH username: vagrant
    ns: SSH auth method: private key
    ns: Warning: Connection timeout. Retrying...
    ns: Warning: Connection timeout. Retrying...
    ns: Warning: Remote connection disconnect. Retrying...
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
vagrant@127.0.0.1's password: 

As you see, vagrant asks password. It continues after I type it. After that, vagrant never ask it whenever I do 'vagrant up'. This occurs at only the first time 'vagrant up'. I wonder something of my custom box's setting, maybe ssh, is wrong but don't understand where the problem is.

Can anybody guess the possible causes?

Environment: the version of vagrant is 1.7.2. Host OS is ubuntu 15.04 and Guest OS is CentOS 6.6.

cul8er
  • 173
  • 1
  • 8
  • When you say "first time", do you mean after a `vagrant destroy`? I mean... what is "first time"? Besides, are you using any box? – tomasyany Jul 09 '15 at 02:24
  • I mean, 'first time' is the first time of 'vagrant up' just after 'vagrant init'. I think it's almost same timing to do 'vagrant up' just after 'vagrant destroy'. And I'm using anoter box which can be found at Atras(https://atlas.hashicorp.com/chef/boxes/centos-6.6). In addition, this is my first time to make a custom vagrant box. I'm absolutely new to this. – cul8er Jul 09 '15 at 06:17
  • Similar to your problem: http://stackoverflow.com/questions/25758737/vagrant-login-as-root-by-default – tomasyany Jul 10 '15 at 15:16

3 Answers3

3

You may also want to try the default vagrant password: vagrant.

Bernard Ojengwa
  • 427
  • 6
  • 12
2

Vagrant asks for the password when it can't login automatically. The most obvious reason is that Vagrant does not have the required user key for the user vagrant. Then your entering the correct password and vagrant exchanges the key. Afterwards this does not appear anymore. This key exchange is manager per instance, so if you destroy/delete the instance then next time your ask again to login manually.

Vagrant offers an insecure key on Github and any distributed public available Vagrant box is packaged with it. You can put this key by executing this inside the machine:

wget https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/vagrant/.ssh/authorized_keys

The other way is to use your own private key and configure the Vagrantfile to use the specific key: Vagrant SSH Config

Vagrant itself will recognize and exchange the insecure key immediately and exchange it for a secure one. Therefore, you have to set this key with Hashicorp Packer.

blacklabelops
  • 4,708
  • 5
  • 25
  • 42
  • I ran this `wget ...` inside the vm and now I get `default: Warning: Authentication failure.` instead of the password prompt. Did I miss something? have I broken my VM or is there another way to login? – Martin Massera Oct 13 '16 at 15:33
  • Please check this [Issue](https://github.com/mitchellh/vagrant/issues/7610) – blacklabelops Oct 13 '16 at 16:06
0

I entered the password "vagrant" when this happened to me and got right in. See this Vagrant Github issue. Also see this stackoverflow question.

Community
  • 1
  • 1
Jim
  • 13,430
  • 26
  • 104
  • 155