SSH Authentication Timing Out

Another bug today! Been pulling my hair out about this one. When I attempted to ‘vagrant ssh’ in this morning I couldn’t log in. Afterwards, when I vagrant up', it timeouts at the SSH Authentication phase.

To spare you from pasting the entire VAGRANT_LOG, I’m pasting in what I think is the most relevant bit:

 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: ["/Users/SimonBloom/.vagrant.d/insecure_private_key"]
 INFO subprocess: Starting process: ["/usr/local/bin/VBoxManage", "showvminfo", "31cb5c43-866d-4db5-8b12-aa1135a774c3", "--machinereadable"]
 INFO subprocess: Command not in installer, restoring original environment...
 INFO subprocess: Starting process: ["/usr/local/bin/VBoxManage", "showvminfo", "31cb5c43-866d-4db5-8b12-aa1135a774c3", "--machinereadable"]
 INFO subprocess: Command not in installer, restoring original environment...
 INFO subprocess: Starting process: ["/usr/local/bin/VBoxManage", "showvminfo", "31cb5c43-866d-4db5-8b12-aa1135a774c3", "--machinereadable"]
 INFO subprocess: Command not in installer, restoring original environment...
 INFO subprocess: Starting process: ["/usr/local/bin/VBoxManage", "showvminfo", "31cb5c43-866d-4db5-8b12-aa1135a774c3", "--machinereadable"]
 INFO subprocess: Command not in installer, restoring original environment...
 INFO subprocess: Starting process: ["/usr/local/bin/VBoxManage", "showvminfo", "31cb5c43-866d-4db5-8b12-aa1135a774c3", "--machinereadable"]
 INFO subprocess: Command not in installer, restoring original environment...
 INFO subprocess: Starting process: ["/usr/local/bin/VBoxManage", "showvminfo", "31cb5c43-866d-4db5-8b12-aa1135a774c3", "--machinereadable"]
 INFO subprocess: Command not in installer, restoring original environment...
 INFO subprocess: Starting process: ["/usr/local/bin/VBoxManage", "showvminfo", "31cb5c43-866d-4db5-8b12-aa1135a774c3", "--machinereadable"]
 INFO subprocess: Command not in installer, restoring original environment...
 INFO subprocess: Starting process: ["/usr/local/bin/VBoxManage", "showvminfo", "31cb5c43-866d-4db5-8b12-aa1135a774c3", "--machinereadable"]
 INFO subprocess: Command not in installer, restoring original environment...
 INFO subprocess: Starting process: ["/usr/local/bin/VBoxManage", "showvminfo", "31cb5c43-866d-4db5-8b12-aa1135a774c3", "--machinereadable"]
 INFO subprocess: Command not in installer, restoring original environment...
 INFO subprocess: Starting process: ["/usr/local/bin/VBoxManage", "showvminfo", "31cb5c43-866d-4db5-8b12-aa1135a774c3", "--machinereadable"]
 INFO subprocess: Command not in installer, restoring original environment...
 INFO subprocess: Starting process: ["/usr/local/bin/VBoxManage", "showvminfo", "31cb5c43-866d-4db5-8b12-aa1135a774c3", "--machinereadable"]
 INFO subprocess: Command not in installer, restoring original environment...
 INFO subprocess: Starting process: ["/usr/local/bin/VBoxManage", "showvminfo", "31cb5c43-866d-4db5-8b12-aa1135a774c3", "--machinereadable"]
 INFO subprocess: Command not in installer, restoring original environment...
 INFO subprocess: Starting process: ["/usr/local/bin/VBoxManage", "showvminfo", "31cb5c43-866d-4db5-8b12-aa1135a774c3", "--machinereadable"]
 INFO subprocess: Command not in installer, restoring original environment...
 INFO subprocess: Starting process: ["/usr/local/bin/VBoxManage", "showvminfo", "31cb5c43-866d-4db5-8b12-aa1135a774c3", "--machinereadable"]
 INFO subprocess: Command not in installer, restoring original environment...
 INFO ssh: SSH not ready: #<Vagrant::Errors::SSHConnectionTimeout: Vagrant timed out while attempting to connect via SSH. This usually
means that the VM booted, but there are issues with the SSH configuration
or network connectivity issues. Please try to `vagrant reload` or

I’ve tried uninstalling both Virtual Box and Vagrant, as well as a lot of the Stack Overflow / Trellis repo solutions I could find.

This is on a completely clean Trellis, Vagrant, and Virtual Box install.

Any help would be massively appreciated! And please let me know if you require any more info.

Throwing out a guess, but it might be possible if you’re using the same IP or URL but created a new box, that the known_hostsis saved to an old box and SSH thinks there is a man in the middle attack.

Can you try SSH-ing into the box manually and see if it complains about that?

I tried to ssh in (ssh 127.0.0.1:2222 ) but I get a ssh: Could not resolve hostname 127.0.0.1:2222: nodename nor servname provided, or not known

If I create a new vagrant box as per the docs (using hashcorp/precise32) I don’t have the ssh issue. (though it does say: default: Vagrant insecure key detected. Vagrant will automatically replace default: this with a newly generated keypair for better security.)

update: I just tried vagrant ssh and it took a long time to connect, but it was successful (albeit incredibly laggy)

If it’s a bug, then it should be reported upstream to Vagrant.

Sorry, I misspoke - it’s way more likely my configuration is just incorrect rather than it being something wrong with Vagrant.

@sbloom did you figure out a solution for this?

Sort of.

The issue had something to do with the network configuration where I was. When I moved to a different location, the problem subsided.

My instinct tells me it’s a router issue, but this was beyond my understanding to diagnose more directly.

Simon

Unfortunately, you’re not the only one having problems with the SSH Authentication on some networks:

https://discourse.roots.io/t/warning-connection-timeout-only-on-certain-networks/6161/4
https://discourse.roots.io/t/first-time-using-trellis-and-stuck-in-vagrant-up-getting-warning-connection-timeout-retrying/6202/9

I got this in spades now.

on vagrant up:

Bringing machine 'default' up with 'virtualbox' provider...

==> default: Importing base box ‘bento/ubuntu-16.04’…
==> default: Matching MAC address for NAT networking…
==> default: Checking if box ‘bento/ubuntu-16.04’ is up to date…
==> default: Setting the name of the VM: tiogadigital.dev
==> 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: 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: private key
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.

in the console in virtualbox 5.0.26
I get a console line looking like this:

[***   ] A start job is running for Raise network interfaces (2min 55s / 5min 4s)

once it hits 5m4s, it flashes a very quick error and finished booting to the login:

and in the Vbox console I have, after it does in fact boot, able to login with vagrant/vagrant and when I ifconfig,
there is NO 192.168.50.5 assigned to an interface… and in the syslog a lot of lines about

Oct 18 12:34:56 vagrant dhclient[1060]: DHCPDISCOVER on enp0s3 to 255.255.255.255 port 67 interval 8 (xid=yadayada)

(I believe that’s a clue for this) AND when I try

$ ssh vgrant@127.0.0.1:2222
ssh: Could not resolve hostname 127.0.0.1:2222: nodename nor servname provided, or not known

oof. and no, ‘vagrant ssh’ no work no how

so it’s clear the dhcp client process has a hitch in its giddy-up.

And since I’m not sure I can post a pic of the console (it’s not copy/paste-able) this tweet has a pic of the error messages inside of the /var/log/syslog of the vagrant host on virtualbox.

kyounger: ugh. this is the syslog errors in my analysis this afternoon. #trellis @rootswp pic.twitter.com/LkgbGtkhjO

oh cripes.

so I did a

vagrant halt

and during the shutdown…

==> default: Attempting graceful shutdown of VM…
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest…
default: Removing insecure key from the guest if it’s present…
default: Key inserted! Disconnecting and reconnecting using new SSH key…

whaatt?

I followed by a

vagrant up

and things are provisioning.

So to recap what I will try next time I have to do this:

vagrant up

until the timeout happens and the shell returns

vagrant halt

hopefully the output will declare the bit about

default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.

and then

vagrant up

again.