63585

Authentication failure when using vagrant up with a barebones custom package

Question:

I'm new to Vagrant, so I'm taking baby steps to make sure that I understand the process. I want to ensure that I can create a custom package before I start doing any serious development in the virtual machine. For now, I have simply used the official <a href="https://app.vagrantup.com/ubuntu/boxes/xenial64" rel="nofollow">ubuntu/xenial64 Vagrant box</a>, and provisioned it so that nginx is installed. You can find <a href="https://www.evernote.com/shard/s175/sh/404e9e81-2858-4c0b-821f-3588cde5a556/6c59e2415223c01b074127ecd27d3d74" rel="nofollow">my step-by-step guide to this here</a>.

My customized box works fine. I use vagrant package --output nginx.box and then vagrant box add nginx nginx.box to add my custom box to my Vagrant Install. It is when I try creating a new box from the custom package that my problem appears.

I create a new directory and use vagrant init nginx to create a clone of my custom box, but when I use vagrant up, Vagrant fails to authenticate:

==> 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: private key default: Warning: Connection reset. Retrying... default: Warning: Remote connection disconnect. Retrying... default: Warning: Connection reset. Retrying... default: Warning: Remote connection disconnect. Retrying... default: Warning: Connection reset. Retrying... default: Warning: Remote connection disconnect. Retrying... default: Warning: Connection reset. Retrying... default: Warning: Remote connection disconnect. Retrying... default: Warning: Connection reset. Retrying... default: Warning: Remote connection disconnect. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying...

If I connect to the VM through VirtualBox Manager, I'm asked to authenticate, and using the login and password "vagrant" fails.

I've looked at <a href="https://stackoverflow.com/questions/29024855/vagrant-up-authentication-failure" rel="nofollow">this question</a> and <a href="https://stackoverflow.com/questions/28284112/vagrant-authentication-failure-during-up-but-vagrant-ssh-can-get-in-just-fi" rel="nofollow">this other question</a> which describe similar symptoms, but I haven't yet found a solution to my problem in the answers. When I run vagrant up --debug, I get <a href="https://www.evernote.com/shard/s175/sh/39c1252f-99b3-4e72-82e5-e734a0c16ec4/a3b18bc9f82c36681743622f4bc302e1" rel="nofollow">this output</a> repeating after the VM has spun up. The key passage seems to be:

DEBUG ssh: == Net-SSH connection debug-level log END == INFO ssh: SSH not ready: #<Vagrant::Errors::SSHAuthenticationFailed: SSH authentication failed! This is typically caused by the public/private keypair for the SSH user not being properly set on the guest VM. Please verify that the guest VM is setup with the proper public key, and that the private key path for Vagrant is setup properly as well.>

What do I need to do before I package my custom box so that any developer will be able to use it without performing any voodoo on the public and private keys?

Answer1:

This box is password authenticated, when you install the box, you can check its Vagrantfile for the password (on my Mac, I will see the file at ~/.vagrant.d/boxes/ubuntu-VAGRANTSLASH-xenial64/20170116.1.0/virtualbox)

config.ssh.username = "ubuntu" config.ssh.password = "95bf98670a543bcd7bdd576c"

The easiest would probably to repackage this same file when you build your own box (see <a href="https://www.vagrantup.com/docs/cli/package.html#vagrantfile-file" rel="nofollow">https://www.vagrantup.com/docs/cli/package.html#vagrantfile-file</a>), so on your step

<blockquote>

Repackage as a new Vagrant Box:

vagrant package --output nginx.box

</blockquote>

I would run

vagrant package --vagrantfile <path_to_original_box_vagrantfile> --output nginx.box

Recommend

  • GCC constexpr lambdas in constexpr functions and evaluation in compile time
  • how to input multiple strings followed by newline
  • Define the position of object in excel sheet
  • Keep executing flow even with a 404 response
  • Graphql, how to return empty array instead of null
  • c++ read pixels with GetDIBits()
  • Talend: How to import this csv file in SQL?
  • Getting the recepient count from email sent in Android
  • how to unsubscribe for an observable
  • Pass variable to a detail view controller using a table in UIViewController (not UITableViewControll
  • LCS ALGORITHM ( example )
  • Android upgrade db not updating db version after successful upgrade
  • How to Prevent the page background image from stretching in jQuery mobile 1.4.0?
  • select query in wordpress
  • best way to remove the first word in a string in Java
  • Login View controller before SWRevealViewController
  • WPF binding to property of all items in a collection
  • How to change the default browser in visual studio code latest released?
  • Memory leak in Ionic(or angular)?
  • about iOS target version and SDK version
  • Intersection of characters in two strings
  • How do I get the standard Vim FTP command to work?
  • getting the values of checkboxes in a checkboxlist control
  • How to add ng-app after page load?
  • Visual Studio MSB3721 error when compiling a __device__ function call from another file
  • create circular Auto Horizontal Scroll View?
  • Getting/building the SQL (with parameters) from NHibernate 3.2
  • SQL query for game rental website - game delivery report
  • internal javascript not works in angular2
  • how to add dashed border on highcharts “area” graph for every point
  • Autocomplete source from project settings
  • How to restrict use of third party camera app from your app
  • C++ STL stack pop operation giving segmentation fault
  • JQuery: Infinite input select
  • DataTables move rows between tables
  • How to specify generic type when the type is only known at runtime?
  • iphone image to video issue in video speed
  • jQuery scrollTop if URL has hash
  • How to integrate angular2-material (alpha 8.2) with angular2-Quickstart app
  • Android Library Projects on Windows and Mac