Skip to content

Instantly share code, notes, and snippets.

@jkeenan
Created August 16, 2016 02:26
Show Gist options
  • Save jkeenan/36ff1789b41d28ef9d5a80916c8b2bd8 to your computer and use it in GitHub Desktop.
Save jkeenan/36ff1789b41d28ef9d5a80916c8b2bd8 to your computer and use it in GitHub Desktop.
'vagrant up' does not complete smoothly

I have a FreeBSD 10.3 virtual machine running inside a VirtualBox 5.1 box sitting on a Linux x86-64 (Ubuntu 16.04 LTS) host. I control the virtual machine via Vagrant 1.8.5. From the Linux command-line I say:

$ cd ~/vagrant
$ vagrant up

... to which the output is:

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> 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: private key
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
[skip approx 30 more instances of this Warning]
    default: Warning: Authentication failure. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.

At this point, when I say:

$ vagrant ssh
Password for vagrant@localhost:

... I get a connection to the FreeBSD virtual machine. On that machine, I am initially logged in as user vagrant, but then I can quickly login as myself.

$ whoami
vagrant
$ pwd
/usr/home/vagrant
$ ls -al
total 40
drwxr-xr-x  2 vagrant  vagrant   512 Aug  9 09:06 .
drwxr-xr-x  4 root     wheel     512 Aug  9 09:06 ..
-rw-r--r--  1 vagrant  vagrant  1066 Aug  9 09:06 .cshrc
-rw-r--r--  1 vagrant  vagrant   252 Aug  9 09:06 .login
-rw-r--r--  1 vagrant  vagrant   163 Aug  9 09:06 .login_conf
-rw-------  1 vagrant  vagrant   379 Aug  9 09:06 .mail_aliases
-rw-r--r--  1 vagrant  vagrant   336 Aug  9 09:06 .mailrc
-rw-r--r--  1 vagrant  vagrant   817 Aug  9 09:06 .profile
-rw-------  1 vagrant  vagrant   281 Aug  9 09:06 .rhosts
-rw-r--r--  1 vagrant  vagrant   978 Aug  9 09:06 .shrc
$ login
login: jkeenan
Password:
Last login: Mon Aug 15 22:14:28 on pts/0
FreeBSD 10.3-RELEASE (GENERIC) #0 r297264: Fri Mar 25 02:10:02 UTC 2016

Welcome to FreeBSD!
[# snip motd]
$ pwd
/usr/home/jkeenan

And at this point I have one terminal with which I can do what I need to do on FreeBSD, viz., running smoke tests of the Perl 5 core distribution on FreeBSD 10.3.

Eventually, I want to log out of my user, out of FreeBSD, and halt vagrant.

$ exit
$ exit
Connection to 127.0.0.1 closed.
[vagrant] 47 $ vagrant halt
==> default: Attempting graceful shutdown of VM...
    default: Guest communication could not be established! This is usually because
    default: SSH is not running, the authentication information was changed,
    default: or some other networking issue. Vagrant will force halt, if
    default: capable.
==> default: Forcing shutdown of VM...

Typically, I don't need to let vagrant up print that Warning out 30+ times. If I Ctrl-C after just one instance of the warning, I get this output:

    default: SSH auth method: private key
    default: Warning: Authentication failure. Retrying...
^C==> default: Waiting for cleanup before exiting...
Vagrant exited after cleanup due to external interrupt.

... but then I can say vagrant ssh and get logged into the FreeBSD VM as before.

[vagrant] 49 $ vagrant ssh
Password for vagrant@localhost:

Needless to say, my objective is to have vagrant up work smoothly, i.e., it should make whatever connection it needs to make to the VM quickly and without 30+ warnings and timing out. It should return to successfully and enable me to say vagrant ssh more quickly.

How do I achieve that objective?

@jkeenan
Copy link
Author

jkeenan commented Aug 22, 2016

INFO interface: detail: SSH username: vagrant
 INFO interface: detail:     default: SSH username: vagrant
    default: SSH username: vagrant
 INFO interface: detail: SSH auth method: private key
 INFO interface: detail:     default: SSH auth method: private key
    default: SSH auth method: private key
 INFO subprocess: Starting process: ["/usr/bin/VBoxManage", "showvminfo", "d51823f5-1b5f-4d01-b09f-072c2f3d189d", "--machinereadable"]
 INFO subprocess: Command not in installer, restoring original environment...
 INFO subprocess: Starting process: ["/usr/bin/VBoxManage", "showvminfo", "d51823f5-1b5f-4d01-b09f-072c2f3d189d", "--machinereadable"]
 INFO subprocess: Command not in installer, restoring original environment...
 INFO ssh: Attempting SSH connection...
 INFO ssh: Attempting to connect to SSH...
 INFO ssh:   - Host: 127.0.0.1
 INFO ssh:   - Port: 2222
 INFO ssh:   - Username: vagrant
 INFO ssh:   - Password? false
 INFO ssh:   - Key Path: ["/home/jkeenan/.vagrant.d/insecure_private_key"]
 INFO subprocess: Starting process: ["/usr/bin/VBoxManage", "showvminfo", "d51823f5-1b5f-4d01-b09f-072c2f3d189d", "--machinereadable"]



 INFO ssh:   - Username: vagrant
 INFO ssh:   - Password? false
 INFO ssh:   - Key Path: ["/home/jkeenan/.vagrant.d/insecure_private_key"]
 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.>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment