Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vagrant asks password at only the first time 'vagrant up'

Tags:

vagrant

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.
[email protected]'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.

like image 848
cul8er Avatar asked Jul 09 '15 00:07

cul8er


People also ask

Why does vagrant ask for password?

One might ask why I am using these settings (because normally vagrant is the default username and password). The reason is because for some reason the box generate some random password and uses ubuntu has the username.

What is the default vagrant password?

According to the Vagrant documentation, there is usually a default password for the user vagrant which is vagrant .

What is root password of vagrant box?

Root Password: "vagrant"


2 Answers

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

like image 110
Bernard Ojengwa Avatar answered Oct 21 '22 17:10

Bernard Ojengwa


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.

like image 2
blacklabelops Avatar answered Oct 21 '22 16:10

blacklabelops