Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant up keep asking for a password

At first I got this error:

Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.

[email protected]'s password:

Then I installed: HighLine

Now I only get:

[email protected]'s password:

I tried to use vagrant has the password.

I did not work. I tried my computer password, it also did not work.

So I have no idea what the password I am supposed to use.

All this started after I added these settings (in Vagrantfile):

config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
config.ssh.keys_only = true
config.ssh.insert_key = true

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.

# Front load the includes
include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__)
load include_vagrantfile if File.exist?(include_vagrantfile)

Vagrant.configure("2") do |config|
  config.vm.base_mac = "02357F2D68C4"
  config.ssh.username = "ubuntu"
  config.ssh.password = "1547c59e6cbdffd4104ad720"

  config.vm.provider "virtualbox" do |vb|
     vb.customize [ "modifyvm", :id, "--uart1", "0x3F8", "4" ]
     vb.customize [ "modifyvm", :id, "--uartmode1", "file", File.join(Dir.pwd, "ubuntu-zesty-17.04-cloudimg-console.log") ]
  end
end

This is found inside of: ~/.vagrant.d/boxes/ubuntu-VAGRANTSLASH-zesty64/20170412.1.0/virtualbox

I tried this solution and it did not work:

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

So what is the password? What can I do so that it stops asking a password?


Vagrant 1.9.1

Local OS:

No LSB modules are available.

Distributor ID: Ubuntu

Description: Ubuntu 17.04

Release: 17.04

Codename: zesty

Box: ubuntu/zesty64 (virtualbox, 20170412.1.0)


UPDATE 1

$ vagrant up

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/zesty64' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'ubuntu/zesty64'
    default: URL: https://atlas.hashicorp.com/ubuntu/zesty64
==> default: Adding box 'ubuntu/zesty64' (v20170412.1.0) for provider: virtualbox
    default: Downloading: https://vagrantcloud.com/ubuntu/boxes/zesty64/versions/20170412.1.0/providers/virtualbox.box
==> default: Successfully added box 'ubuntu/zesty64' (v20170412.1.0) for 'virtualbox'!
==> default: Importing base box 'ubuntu/zesty64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/zesty64' is up to date...
==> default: Setting the name of the VM: -----
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 3306 (guest) => 3306 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: password
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
[email protected]'s password: 
[email protected]'s password: 
    default: Warning: Authentication failure. Retrying...
[email protected]'s password: ==> default: Waiting for cleanup before exiting...
Vagrant exited after cleanup due to external interrupt.
like image 361
jnbdz Avatar asked Aug 02 '17 21:08

jnbdz


2 Answers

Vagrant's Official documentation states that there is a default password for 'vagrant' user which is
vagrant itself . Go to their Official Website to know more

like image 113
Sangeet Avatar answered Sep 28 '22 23:09

Sangeet


I think you have some confusion.

config.ssh.username will reference the user to use to login, but this user must exists in the VM, you cannot decide to use your own name and it will work; if there's no corresponding user in the VM, it will not work.

Vagrant recommends to use key-based authentication rather than a password, but when you create your box (generally using packer.io) you can decide to have password authentication method.

In the case of ubuntu/zesty64 box, thats what the owner has decided to do, it has created only the ubuntu user and has decided to authenticate with a password.

If you prefer to use vagrant to login to the VM, you will first need to create the vagrant user, you can also download the public key. After you make those changes, you can repackage the box so if you want to re-use in future, all setup will be kept. You can also look at building your own box using packer, there are tons of available templates on github that you can re-use.

like image 23
Frederic Henri Avatar answered Sep 29 '22 00:09

Frederic Henri