Jon-Michael Deldin

BMX, bike trials, & software from the Pacific Northwest

Hyperspecific Solution to a Vagrant Authentication Failure

Like a fool, I upgraded my Ubuntu 18.04 machine to 18.10 over the weekend because I needed a new LaTeX package and was too lazy to use tlmgr. On Monday morning, I did my usual make launch and found eight tmux windows reporting a similar message:

==> core: Waiting for machine to boot. This may take a few minutes...
    core: SSH address: 127.0.0.1:2222
    core: SSH username: vagrant
    core: SSH auth method: private key
    core: Warning: Connection reset. Retrying...
    core: Warning: Authentication failure. Retrying...
    core: Warning: Authentication failure. Retrying...
    :
    : ...
    core: Warning: Authentication failure. Retrying...

I don’t know if it’s because I haven’t restarted my computer in a month or two and I’d been hiding the problem, or if it was an unrelated update, but oh well.

After much grumbling, I figured out the problem and its trivial solution. Notice how it says SSH username: vagrant above? It turns out that the Ubuntu-packaged box I’m using configured its username to ubuntu. Set config.ssh.username in your Vagrantfile and be done! Better yet, provision a new box that doesn’t have this same issue.

How do you find out the default credentials?

  1. Note which box your Vagrantfile uses. Mine is ubuntu/xenial64.
  2. Figure out which version of that box your machine is running with some sloppy shell programming. This is really only needed if you have multiple versions like me. The VM’s name in question is core, so substitute whatever yours is below:
    python -mjson.tool < ~/.vagrant.d/data/machine-index/index | grep core -A15 | grep version
           "version": "20171208.0.0"
        
  3. Armed with the version, figure out the username and password for the box:
    grep ssh ~/.vagrant.d/boxes/ubuntu-VAGRANTSLASH-xenial64/20171208.0.0/virtualbox/Vagrantfile
       config.ssh.username = "ubuntu"
       config.ssh.password = "some_password"
        

How do you set the credentials?

  1. Update your Vagrantfile:
    Vagrant.configure("2") do |config|
      config.vm.box = "ubuntu/xenial64"
    
      # ...
      config.ssh.username = "ubuntu"
      # optional, if you want to bypass logging in with a private key
      # config.ssh.password = "some_password"
      # ...
    end
        
  2. Restart your Vagrant box:
    vagrant reload core && vagrant ssh core
        
  3. Rejoice in your time lost to stupid computers. Get back to work.
* * *