6

At first I got this error:

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:

Then I installed: HighLine

Now I only get:

vagrant@127.0.0.1'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...
vagrant@127.0.0.1's password: 
vagrant@127.0.0.1's password: 
    default: Warning: Authentication failure. Retrying...
vagrant@127.0.0.1's password: ==> default: Waiting for cleanup before exiting...
Vagrant exited after cleanup due to external interrupt.
jnbdz
  • 4,863
  • 9
  • 51
  • 93
  • If there is no box and you vagrant up a new one, does it say something along the lines of "insecure keys found. Replacing..."? – Nathan Smith Aug 02 '17 at 21:39
  • There is a box. Where I am supposed to see "insecure keys found. Replacing..."? – jnbdz Aug 02 '17 at 21:45
  • If you're creating a new box from scratch, it'll import the base box, and you should see several lines that start with "client". One should say "Vagrant insecure key detected. Vagrant will automatically replace this with a newly generated keypair for better security", but it will only say this if you are generating a new box. If not, then it is possible your keys are not being copied over, hence you cannot log in. – Nathan Smith Aug 02 '17 at 21:48
  • I did try this: https://stackoverflow.com/questions/31306192/vagrant-asks-password-at-only-the-first-time-vagrant-up but it doesn't work. I will try to reload the box. – jnbdz Aug 02 '17 at 21:54
  • @NathanSmith I just added UPDATE 1. Is it what you were referring too? Do you need more information? – jnbdz Aug 02 '17 at 22:03

2 Answers2

7

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

Sangeet
  • 946
  • 9
  • 12
5

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.

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139