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.
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.
According to the Vagrant documentation, there is usually a default password for the user vagrant which is vagrant .
Root Password: "vagrant"
You may also want to try the default vagrant password: vagrant
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With