Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Vagrant Up stuck at SSH #965

Closed
ameenshake opened this issue Nov 3, 2016 · 32 comments
Closed

Vagrant Up stuck at SSH #965

ameenshake opened this issue Nov 3, 2016 · 32 comments
Labels

Comments

@ameenshake
Copy link

ameenshake commented Nov 3, 2016

Everything was working fine at the start but once I destroyed the vagrant machine to recreate another one, it would give me the following error:

$ vagrant up
Bringing machine 'drupalvm' up with 'virtualbox' provider...
==> drupalvm: Box 'geerlingguy/ubuntu1604' could not be found. Attempting to find and install...
    drupalvm: Box Provider: virtualbox
    drupalvm: Box Version: >= 0
==> drupalvm: Loading metadata for box 'geerlingguy/ubuntu1604'
    drupalvm: URL: https://atlas.hashicorp.com/geerlingguy/ubuntu1604
==> drupalvm: Adding box 'geerlingguy/ubuntu1604' (v1.0.5) for provider: virtualbox
    drupalvm: Downloading: https://atlas.hashicorp.com/geerlingguy/boxes/ubuntu1604/versions/1.0.5/providers/virtualbox.box
==> drupalvm: Successfully added box 'geerlingguy/ubuntu1604' (v1.0.5) for 'virtualbox'!
==> drupalvm: Preparing master VM for linked clones...
    drupalvm: This is a one time operation. Once the master VM is prepared,
    drupalvm: it will be used as a base for linked clones, making the creation
    drupalvm: of new VMs take milliseconds on a modern system.
==> drupalvm: Importing base box 'geerlingguy/ubuntu1604'...
==> drupalvm: Cloning VM...
==> drupalvm: Matching MAC address for NAT networking...
==> drupalvm: Checking if box 'geerlingguy/ubuntu1604' is up to date...
==> drupalvm: Setting the name of the VM: drupalvm.dev
==> drupalvm: Clearing any previously set network interfaces...
==> drupalvm: Preparing network interfaces based on configuration...
    drupalvm: Adapter 1: nat
    drupalvm: Adapter 2: hostonly
==> drupalvm: Forwarding ports...
    drupalvm: 22 (guest) => 2222 (host) (adapter 1)
==> drupalvm: Running 'pre-boot' VM customizations...
==> drupalvm: Booting VM...
==> drupalvm: Waiting for machine to boot. This may take a few minutes...
    drupalvm: SSH address: 127.0.0.1:2222
    drupalvm: SSH username: vagrant
    drupalvm: 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.

I am running this on Ubuntu 16.04. I have tried it all. I have tried increasing the timeout value, removing vagrant + ansible + virtualbox from my machine and reinstalling.

This is what happens when I try to provision:

$ vagrant provision                                                                                                                               
==> drupalvm: Running provisioner: ansible...
    drupalvm: Running ansible-playbook...

PLAY [all] *********************************************************************

TASK [setup] *******************************************************************
fatal: [drupalvm]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Connection timed out during banner exchange\r\n", "unreachable": true}
	to retry, use: --limit @/home/ameenshake/drupalVM/drupal-vm/provisioning/playbook.retry

PLAY RECAP *********************************************************************
drupalvm                   : ok=0    changed=0    unreachable=1    failed=0   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

I have tried setting "config.ssh.forward_agent" to false, I have tried adding config.ssh.username = "vagrant" and config.ssh.password = "vagrant", to no success.

@ccjjmartin
Copy link
Contributor

ccjjmartin commented Nov 3, 2016

@ameenshake I just ran into this and had to:

vagrant destroy
rm -Rf .vagrant # Within your project directory

I am also downgraded to the geerlingguy/ubuntu1404. Once I did that I did a vagrant up and everything was working. Not sure if there is a problem with the 1604 base box right now or not.

EDIT (Feb 22, 2017):
Since I ran into this error myself again I am adding the real fix here:

  • Upgrade all the things (ansible, vagrant, and VirtualBox)
  • NOTE: Later in the thread geerlingguy points out that 5.0.X of VirtualBox is not longer supported. I can report that using the latest 5.0.X (5.0.32), it still works for me.

I upgraded these one at a time and at each layer experienced a different issue but once they are all updated and you spin up a new VM using geerlingguy/ubuntu1404, things should work.

@ameenshake
Copy link
Author

@ccjjmartin Tried but no luck!

@BigEdDev
Copy link

BigEdDev commented Nov 3, 2016

I think this is the same issue I am having on Ubuntu. I ran a unmodified version of drupalvm in dbug mode here's the output.

/.vagrant.d/gems/gems/vagrant-triggers-0.5.2/lib/vagrant-triggers/action/trigger.rb:17:incall'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/warden.rb:34:in call' /opt/vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/builder.rb:116:incall'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/runner.rb:66:in block in run' /opt/vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/util/busy.rb:19:inbusy'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/runner.rb:66:in run' /opt/vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/machine.rb:225:inaction_raw'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/machine.rb:200:in block in action' /opt/vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/environment.rb:561:inlock'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/machine.rb:186:in call' /opt/vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/machine.rb:186:inaction'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/batch_action.rb:82:in block (2 levels) in run' 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.

vagrant destroy
rm -Rf .vagrant # Within your project directory
vagrant_box: geerlingguy/ubuntu1404

These made no difference.

@oxyc
Copy link
Collaborator

oxyc commented Nov 3, 2016

Can you boot the VM using the VirtualBox GUI to see what is halting the process?

You can boot in GUI mode by either using the VirtualBox app or adding a Vagrantfile.local with the following

config.vm.provider :virtualbox do |v|
  v.gui = true
end

@oxyc
Copy link
Collaborator

oxyc commented Nov 3, 2016

#953 is possibly related.

@ccjjmartin
Copy link
Contributor

@BigEdDev oxyc's reference should be helpful. I am noticing that you are running 1.8.5. I had to upgrade vagrant to 1.8.6. Not sure if that would help. You might need to upgrade Ansible and VirtualBox too.

@ccjjmartin
Copy link
Contributor

@ameenshake In my .ssh config I specify the vagrant private key instead of the user name and password. Don't know if this will help:

# drupalvm.dev
host drupalvm 192.168.88.88
hostname drupalvm.dev
user vagrant
IdentityFile ~/.vagrant.d/insecure_private_key

@ameenshake
Copy link
Author

Thank you everyone. I tried all the solutions and updating VirtualBox to 5.1 finally worked!
If anyone is wondering, I had the same issue as #953 as @oxyc suggested.

@mgifford
Copy link

I'm using the latest version of VirtualBox

Checked to see that config.yml is using geerlingguy/ubuntu1404

Ran:

vagrant destroy
rm -Rf .vagrant # Within your project directory

I'm still getting a timeout issue. Not sure what else to try.

@geerlingguy
Copy link
Owner

@mgifford - What versions of VirtualBox and Vagrant are you running? Also, what version of the box do you have (vagrant box list).

@mgifford
Copy link

Maybe I'm using the wrong one.. I have so many!

$ vagrant box list
geerlingguy/ubuntu1404 (virtualbox, 1.0.8)
geerlingguy/ubuntu1404 (virtualbox, 1.1.0)
geerlingguy/ubuntu1404 (virtualbox, 1.1.4)
geerlingguy/ubuntu1604 (virtualbox, 1.0.5)

VirtualBox Version 5.0.28 r111378

Vagrant 1.8.6 (although I just noticed that there is another update so pulling down 1.8.7 now).

@ccjjmartin
Copy link
Contributor

@mgifford Do you have the hostsupdater plugin installed? Do you have anything in your ~/.ssh/config file?

What does vagrant ssh-config show?

@geerlingguy
Copy link
Owner

@mgifford - You need to upgrade VirtualBox to 5.1.6 (or try 5.1.8 if you dare—some people have problems with that version). 5.0.x is no longer supported.

@mgifford
Copy link

@ccjjmartin

Well, did wonders for the ssh timeout....
vagrant plugin install vagrant-hostsupdater

My ~/.ssh/ is filled with the usual dsa/rsa keys. Nothing unusual in ~/.ssh/config

$ vagrant ssh-config
Host drupalvm
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /Users/mikegifford/.vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL
ForwardAgent yes

@geerlingguy

I had totally assumed that if I checked for Updates that VirtualBox would just pull down the latest.. Didn't realize it stayed within the major version release. I'll try 5.1.8 for now and hope it works (It didn't)... So with 5.1.6 now I can get passed the ssh problem, but then run into this error

fatal: [drupalvm]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Connection timed out during banner exchange\r\n", "unreachable": true}

when running vagrant provision

I also see this with vagrant up

=> drupalvm: Checking if box 'geerlingguy/ubuntu1604' is up to date...
==> drupalvm: There was a problem while downloading the metadata for your box
==> drupalvm: to check for updates. This is not an error, since it is usually due
==> drupalvm: to temporary network problems. This is just a warning. The problem
==> drupalvm: encountered was:
==> drupalvm: 
==> drupalvm: 
==> drupalvm: 
==> drupalvm: If you want to check for box updates, verify your network connection
==> drupalvm: is valid and try again.

@geerlingguy
Copy link
Owner

@mgifford - Unfortunately this is likely due to some caching that's going on with Vagrant. Try doing a vagrant box remove to remove all the boxes one by one on your system. Then do a vagrant up (a full restart in between can help too). Then things should be good.

Ugh, sometimes Vagrant and VirtualBox love making my life miserable :P

@choicelildice
Copy link

Not sure if this helps, but I'm literally following along with every post and nodding along this morning, as I've had the EXACT same issues since yesterday morning. I can boot up an existing VM, but provisioning a new one freezes on "SSH auth method: private key." I also get the error listed in the comment above "There was a problem while downloading the metadata for your box" etc. I'll try geerlingguy's comment above and let you all know how it goes.

@choicelildice
Copy link

choicelildice commented Nov 11, 2016

As an update, I switched to php7 and ubuntu 1604 and got past the issue. So it seems to be only happening on 1404.

@geerlingguy
Copy link
Owner

geerlingguy commented Nov 11, 2016

@choicelildice - The problem is the 14.04 box is cached locally—you'd need to downgrade to an older version, and then update to the latest box version again. Also try VirtualBox 5.1.6.

@choicelildice
Copy link

@geerlingguy Thanks for jumping in to help. I went ahead and removed all the boxes. When I type 'vagrant box list' I now get: 'There are no installed boxes! Use vagrant box add to add some.' However, when I run vagrant up I'm now getting this error:

"==> cga: Box 'geerlingguy/ubuntu1404' could not be found. Attempting to find and install...
cga: Box Provider: virtualbox
cga: Box Version: >= 0
The box 'geerlingguy/ubuntu1404' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Atlas, please verify you're logged in via
vagrant login. Also, please double-check the name. The expanded
URL and error message are shown below:

URL: ["https://atlas.hashicorp.com/geerlingguy/ubuntu1404"]
Error:"

There is nothing below that "Error:" prompt. I have updated drupalvm, vagrant, and virtualbox to the most recent version. Any insight you can give would be really helpful.

@choicelildice
Copy link

If I try to add the box manually, I run into a similar issue:

vagrant box add geerlingguy/ubuntu1604 https://atlas.hashicorp.com/geerlingguy/boxes/ubuntu1604/versions/1.0.5/providers/virtualbox.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'geerlingguy/ubuntu1604' (v0) for provider:
box: Downloading: https://atlas.hashicorp.com/geerlingguy/boxes/ubuntu1604/versions/1.0.5/providers/virtualbox.box
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.

@choicelildice
Copy link

I just tried downgrading virtualbox to 5.1.6, unfortunately no luck.

@choicelildice
Copy link

For anyone looking here that had the same issues as me:

This was the solution to my problem:
hashicorp/vagrant#7969

I simply ran 'sudo rm -rf /opt/vagrant/embedded/bin/curl'

Thanks

@geerlingguy
Copy link
Owner

@choicelildice - See also notes on #981

@mgifford
Copy link

It's all up and working for me again now. Thanks again for all the help!

@geerlingguy
Copy link
Owner

Great!

@DanaHazelton-githubRep
Copy link

Battled the timeout issue for 2 weeks.. tried multiple vagrant boxes/virtualbox versions blah..blah..blah
nothing worked until I did the following.
Vagrantfile2.txt

Venture into your .vagrant.d file, there you will find a file insecure_private_key. I am linuxmint 18.2 and when I clicked on the file it opened and gave me the option to import it. I imported in giving a name of insecure_private_key. It looks as if it imported in Gnome2(?). Any ways after doing this the machine booted and the inline script ran flawlessly.

OS - linux mint 18.2 32byte
Vagrant - 2.0.0
VirtualBox 5.1.28r117968

Hope this helps..

@DanaHazelton-githubRep
Copy link

looks like you can now $cd /vargrant and you will be on your VM.

@hissDev
Copy link

hissDev commented Nov 7, 2017

Had this timeout problem on ubuntu 14tls. Found the following solution for me on other posts:

  • stop the vm - vagrant halt
  • open the VirtualBox UI, select the image and go to settings/network/Advanced/ -> check Cable Connected
  • start again - vagrant up

hope it can help :)

@cjamesrun
Copy link

open the VirtualBox UI, select the image and go to settings/network/Advanced/ -> check Cable Connected
worked for me, is there any way to include that checkbox in the building of the VM?

@atannerd
Copy link

atannerd commented Mar 1, 2018

open the VirtualBox UI, select the image and go to settings/network/Advanced/ -> check Cable Connected

That worked for me as well

@robinmathews
Copy link

Hi, if you are setting Vagrant in an ubuntu machine hosted in Windows, then you need to enable virtualization(VT_X) in your bios as well as in the VMware in which ubuntu is running. Also increase the no of processors and cores.

@tyy0402
Copy link

tyy0402 commented Sep 27, 2018

  • open the VirtualBox UI, select the image and go to settings/network/Advanced/ -> check Cable Connected

How can I open UI on ubuntu?
Thanks!

AndyMacDroo added a commit to AndyMacDroo/ubuntu-development-environment-playbook that referenced this issue Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests