Laravel Homestead hangs at SSH auth method: private key on mac - macos

I can't seem to get Homestead running. It hangs at SSH auth method: private key.
The Homestead VM starts. I can go to VirtualBox and open the terminal window and login with vagrant:vagrant.
I can't vagrant ssh, ssh vagrant#127.0.0.1:2204 or ssh vagrant#127.0.0.1 -p 2204.
None of my folders show up in the VM, but the VirtualBox says they are mapped.
Every time I vagrant up, I get:
vagrant up
Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Checking if box 'laravel/homestead' is up to date...
==> homestead-7: Clearing any previously set forwarded ports...
==> homestead-7: Fixed port collision for 80 => 8000. Now on port 2200.
==> homestead-7: Fixed port collision for 443 => 44300. Now on port 2201.
==> homestead-7: Fixed port collision for 3306 => 33060. Now on port 2202.
==> homestead-7: Fixed port collision for 5432 => 54320. Now on port 2203.
==> homestead-7: Fixed port collision for 22 => 2222. Now on port 2204.
==> homestead-7: Clearing any previously set network interfaces...
==> homestead-7: Preparing network interfaces based on configuration...
homestead-7: Adapter 1: nat
homestead-7: Adapter 2: hostonly
==> homestead-7: Forwarding ports...
homestead-7: 80 (guest) => 2200 (host) (adapter 1)
homestead-7: 443 (guest) => 2201 (host) (adapter 1)
homestead-7: 3306 (guest) => 2202 (host) (adapter 1)
homestead-7: 5432 (guest) => 2203 (host) (adapter 1)
homestead-7: 22 (guest) => 2204 (host) (adapter 1)
==> homestead-7: Running 'pre-boot' VM customizations...
==> homestead-7: Booting VM...
==> homestead-7: Waiting for machine to boot. This may take a few minutes...
homestead-7: SSH address: 127.0.0.1:2204
homestead-7: SSH username: vagrant
homestead-7: 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 replaced the homestead insecure private key with my key on my box. I see a lot of people get Warning: Connection timeout. Retrying..., but I don't get that far.
I'm on a mac 10.11.6
Any help would be greatly appreciated!

I had the same problem on macOS 10.12 today, and lost 6 hours trying to find a fix. Finally, after several reinstallations, reboots, and trial and error, I somehow got it to work by following these steps...
Completely uninstall and reinstall Vagrant, VirtualBox, and Homestead.
Ensure the homestead-7 box is shut down within the VirtualBox UI
Right-click the homestead-7 box, and choose Settings
Click 'Network'
Under 'Adapter 1', which should be attached to NAT, click 'Advanced'
Tick the box beside 'Cable Connected'
Save settings, and reprovision Homestead with vagrant up --provision
Run vagrant reload --provision to reprovision the machine
That should be it! I was able to SSH in after this, but not able to view Homestead sites through the browser (even though I'd configured the /etc/hosts file), but a simple reboot of the Mac seemed to fix this.
Given I don't know what exactly caused this in the first place, this might just be a bit of luck for my case, but let me know how you get on.

Open VirtualBox UI and enter the virtual machine.
press Enter key to make system continue to boot.
And then you can see the vagrant up going on.

I had this problem. I enabled Vt-x in the bios and it cleared it.

Vagrant 2.1.2
vagrant destroy then vagrant up --provision worked for me.
I have noticed that it usually happens when new version of vagrant released

If you are on Windows, you have done everything here and still have trouble, maybe this is the solution you need.
Open the Command Prompt as an administrator. Type the bcdedit command. You may find hypervisorlaunchtype Auto. If that is the case, type bcdedit /set hypervisorlaunchtype off to turn it off. Reboot and try again.
Hope this helps.

Nothing here worked for me. I got into the situation of SSH auth method: private key because my mac black screened and crashed.
All that worked for me was a vagrant destroy then vagrant up --provision. Beware this will of course trash anything in your VM. but you should be using ephemeral principles anyway...

Enable "Virtualization Technology" in BIOS settings

I had to do a fsck. (disclaimer, I typed the commands from memory)
Open VirtualBox UI and enter the virtual machine.
If you see (initramfs), type exit
fsck /dev/mapper/vagrant-vg-root -y
reboot
Go back to your normal terminal and try a:
vagrant halt
vagrant up
For me, things were back to normal from here.

This happened to me all of a sudden after working fine for a while using Homestead v6.4 with virtualbox. To fix, Open VirtualBox - if using - and check the logs there.
I found instructions to manually fsck a directory which fixed the issue
Your directory will likely be different, but mine was
fsck /dev/mapper/homestead--vg-root
And then select y to fix all of the errors

Try to call vagrant up from CMD with admin rights

If you're still stuck, here's something you can quickly rule out:
For me the issue was too little video memory, for some reason in Virtual Box my video memory was set to 4mb, the minimum is 12mb, I set it to 24mb (with vm off) and ran vagrant up again, and it fixed the issue!

I got this error after installing Docker Desktop for Windows.
The two aren't compatible.
run Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Hypervisor
this will disable hypervisor.
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
to enable.
I've found that now Homestead takes a long time to boot, Open VMBox, select homestead and click on Show (green button). Wait until you have the homestead login prompt.
Then go back & you can run vagrant ssh into Homestead.

Related

Vagrant times out waiting for machine to boot (Virtualbox)

To preface, I realize this is a common error message with several different causes and solutions, but nothing I've found has worked so far. I have Vagrant 2.1.5 with Virtualbox 5.2.18, running on Windows 10.
I was testing Vagrant with a very simple Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
end
Running vagrant up then gives the typical "Timed out while waiting for the machine to boot" error:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos/7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'centos/7' is up to date...
==> default: Setting the name of the VM: vargrantTest_default_1537805339381_15444
==> 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
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.
Things I have tried:
Ensuring virtualization is enabled in BIOS
Increasing boot timeout in vagrantfile
Ensuring the VMs network settings are correct in Virtualbox (NAT adapter with cable connected)
Using vb.gui = true to watch the VM boot. It boots fine and waits at the login screen.
Using --debug flag on vagrant up. This doesn't give any obvious errors that I found, though before timing out it runs VBoxManage showvminfo --machinereadable several hundred times, resulting in a log file of over 80k lines.
As well as several other things I forgot to write down. I'm out of ideas and quite new to Vagrant, so I don't really know what the next step of troubleshooting this is. Any help would be appreciated.
Edit: Not sure why I didn't think to do it myself, but Marco gave me the idea to try to ssh directly to the VM. I tried doing so using the key file in "/.vagrant.d/insecure_private_key" created by Vagrant, but it timed out. I then tried to simply ping the VM, but doing so gives a seemingly random mix of "Request timed out" and "Destination host unreachable", so there's probably a bigger network issue somewhere (my machine, the VM, or Virtualbox) I'm unaware of.
Are you declaring some kind of network for this box? Either private or public, but something?
Also, how long is your boot timeout? Go overboard and give it 900=>15mn.

Vagrant/virtualbox no SSH connection and timeout (Windows)

I a trying to setup this machine: https://github.com/ByteInternet/hypernode-vagrant
When I do vagrant up i get following error: Timed out while waiting for the machine to boot.
Full context of the error:
$ vagrant up
Bringing machine 'hypernode' up with 'virtualbox' provider...
==> hypernode: Will use PHP 7. If you want PHP 5.5 instead change the php version in local.yml.
==> hypernode: Checking if box 'hypernode_php7' is up to date...
==> hypernode: Clearing any previously set forwarded ports...
==> hypernode: Clearing any previously set network interfaces...
==> hypernode: Preparing network interfaces based on configuration...
hypernode: Adapter 1: nat
hypernode: Adapter 2: hostonly
==> hypernode: Forwarding ports...
hypernode: 80 (guest) => 8080 (host) (adapter 1)
hypernode: 3306 (guest) => 3307 (host) (adapter 1)
hypernode: 22 (guest) => 2222 (host) (adapter 1)
==> hypernode: Running 'pre-boot' VM customizations...
==> hypernode: Booting VM...
==> hypernode: Waiting for machine to boot. This may take a few minutes...
hypernode: SSH address: 127.0.0.1:2222
hypernode: SSH username: vagrant
hypernode: 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.
When I boot the VM manually, I can see the networking is not working as it should be. There is no connection. When I change the VM's settings to bridged network the networking does work. But the vagrant is configured as NAT. So any changes I make in the settings or in the vagrant file seem to be resetting back.
I tried Vagrant 1.9.3, 1.9.2 and 1.9.0 on two different PC's. I am using Virtualbox 5.1.18. When I filter down the logs with "NAT" is see following errors (this is not the complete log, only a small portion):
00:00:00.575454 SUP: Loaded VMMR0.r0 (C:\Program Files\Oracle\VirtualBox\VMMR0.r0) at 0xfffff80c897b0000 - ModuleInit at fffff80c897d3590 and ModuleTerm at fffff80c897d3a80 using the native ring-0 loader
00:00:01.681747 Driver = "NAT" (cb=4)
00:00:01.962037 SUP: Loaded VBoxDDR0.r0 (C:\Program Files\Oracle\VirtualBox\VBoxDDR0.r0) at 0xfffff80c898d0000 - ModuleInit at 0000000000000000 and ModuleTerm at 0000000000000000 using the native ring-0 loader
00:00:02.196495 NAT: Guest address guess set to 10.0.2.15 by initialization
00:00:02.204465 NAT: DNS#0: 192.168.178.1
00:00:02.271317 NAT: Failed to redirect TCP 127.0.0.1:2222 -> 0.0.0.0:22 (Unknown error)
00:00:02.271732 NAT: Failed to redirect TCP 0.0.0.0:3307 -> 0.0.0.0:3306 (Unknown error)
00:00:02.272033 NAT: Failed to redirect TCP 0.0.0.0:2200 -> 0.0.0.0:80 (Unknown error)
00:00:09.976199 NAT: Link up
00:00:39.428974 NAT: DHCP offered IP address 10.0.2.15
00:00:39.429404 NAT: DHCP offered IP address 10.0.2.15
00:03:02.167191 NAT: DHCP offered IP address 10.0.2.15
00:03:02.167820 NAT: DHCP offered IP address 10.0.2.15
00:07:58.531621 NAT: Zone(nm:mbuf_cluster, used:0)
00:07:58.532221 NAT: Zone(nm:mbuf_packet, used:0)
00:07:58.532232 NAT: Zone(nm:mbuf, used:1)
00:07:58.532419 NAT: Zone(nm:mbuf_jumbo_pagesize, used:0)
00:07:58.532961 NAT: Zone(nm:mbuf_jumbo_9k, used:0)
00:07:58.533255 NAT: Zone(nm:mbuf_jumbo_16k, used:0)
00:07:58.533424 NAT: Zone(nm:mbuf_ext_refcnt, used:0)
00:07:58.536529 Changing the VM state from 'DESTROYING' to 'TERMINATED'
How can I solve or debug this?
UPDATE
Last couple of days I also retried with different version of virtualbox and Vagrant listed below without any results:
Virtualbox 5.0.18
Virtualbox 5.0.20
Virtualbox 5.0.36
Vagrant 1.9.3
I also tried another box, which has the same problem. So it seems it's not the box but the host.
Furthermore I tried a setup on a Windows 7 machine with exactly the same results. I think I am missing something in the configuration but I don't know what since there is not a definitive guide to get this working on a Windows machine.
UPDATE 2: Could it be possible the machines I try this on do not support this kind of a setup? I tried looking for virtualizations options in the BIOS.
UPDATE 3: When I do ssh -v 127.0.0.1 -p 1222 from my host to the guest I get following error. SSH service is up and running on the guest. I checked with sshd service status.
$ ssh -v 127.0.0.1 -p 1222
OpenSSH_7.3p1, OpenSSL 1.0.2k 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 1222.
debug1: connect to address 127.0.0.1 port 1222: Connection refused
ssh: connect to host 127.0.0.1 port 1222: Connection refused
UPDATE 4: I cannot ping any internet IP's or domains from the guest machine.
UPDATE 5: SOLVED! Switched to Linux for quite a while now. Best decision ever :D
First of al, changing the first interface to NAT is normal behavior. It's a requirement in order to make vagrant work.
You can check two things:
1) preferences > network > nat-network. (settings should be like this):
network settings
2) make sure you're virtual cable is connected
cable connected
3) maybe you can try another vagrant box.
When I have this error on Windows 10 Pro:
...
homestead: SSH auth method: private key
Timed out while waiting for the machine to boot. ...
...
I have found that all I need to do is have the VirtualBox GUI open and the VM selected while running this on a command line:
vagrant reload --provision
If the GUI is closed, it repeatedly times out that throws the error above.
If the GUI is opened, then the process continues as normal with no errors, and everything starts working.
I have also found that sometimes after automatic Windows restarts, my network adapter does not have the VirtualBox NDIS6 Bridged Networking Driver installed, and that can also cause this error.
This can be fixed by opening the network connection properties and clicking Install -> Service -> Oracle Corporation -> VirtualBox NDIS6 Bridged Networking Driver to install the driver.
It should just appear in the list without having to go through a driver install, but if you somehow never had that driver installed before, then this might put you through a driver install process.
On Windows, the typical path to the folder with that driver in it is below. You probably won't have to manually install anything, but in case you do, open that folder and then Right-Click -> Install the VBoxNetFlt.inf file.
%ProgramFiles%\Oracle\VirtualBox\drivers\network\netflt

Vagrant Windows - ssh_exchange_identification: read: Connection reset by peer

It seems I can't SSH to my virtual box.
I have a virtual box running with Win7. The host PC is also in Win7.
The virtual box was created through Vagrant with the following Vagrantfile.
Vagrant.configure("2") do |config|
config.vm.box = "http://aka.ms/vagrant-win7-ie11"
end
Open cmd. Go to the root folder of the VagrantFile.
Execute the following command:
vagrant up
cmd displays:
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
Timed out while waiting for the machine to boot...
Time out appears though the virtual box has already finished the boot. (Checking via VirtualBox Manager)
Execute the following command:
vagrant ssh
cmd displays:
ssh_exchange_identification: read: Connection reset by peer
While debugging the vagrant ssh, I may have found some useful logs:
INFO subprocess: Starting process: ["C:\\Program Files\\Git\\usr\\bin/ssh.EXE"]
INFO ssh: Invoking SSH: ss ["vagrant#127.0.0.1", "-p", "2222", "-o", "Compression=yes", "-o", "DSAAuthentication=yes", "-o", "LogLevel=FATAL", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "-o", "IdentitiesOnly=yes", "-i", "C:/Users/hostpcname/.vagrant.d/insecure_private_key"]
Can you suggest some ways on how to get out of this?
I've tried the non-Windows image - hashicorp/precise64, and it worked fine.
I have the same issue. Do by follow this step and working for me.
vagrant reload
and
vagrant ssh
again and working fine
These steps will work
vagrant halt
open virtual box and uncheck hardware virtualization , save it
vagrant up
vagrant ssh
Note: vagrant halt is must, settings can't be edited in running state
The following commands worked for me.
vagrant halt
vagrant up
vagrant ssh
Enable de virtualization on BIOS
After rebooting my computer and enabling intel virtualization in BIOS, I was able to get past this.
I was getting error as : ssh_exchange_identification connection reset by peer
Please follow below link ,it worked for me.
https://talk.openmrs.org/t/error-on-vagrant-up/8833/30
Step:
Please open virtualbox and check if any vm is running.
Run vagrant destroy to remove all vms created by current Vagrantfile.
Remove .vagrant directory in the bahmni-vagrant directory.
Make sure you have the same Vagrantfile file as https://github.com/Bahmni/bahmni-vagrant/blob/master/Vagrantfile 37.
Run vagrant up. Monitor virtualbox while it is starting up.

vagrant up timing out on Windows 10

I'm trying to boot up a vagrant instance but it seems to hang at the default: SSH auth method: private key part no matter what I do. I'm new to vagrant so it's entirely possible that there's something I haven't done but should have.
System info:
Windows 10 build 10586.420
Vagrant 1.8.4
VirtualBox 5.0.22 r108108
vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'hashicorp/precise64' is up to date...
==> 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
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 had a look around for similar issues and people have suggested making sure Hyper-V is disabled (which it is) and enabling the virtualbox GUI to see if there are any other errors that aren't being put in the command line.
When I open the virtualbox GUI, I see a username/password prompt (see below):
I've tried entering the default vagrant username/passwords and these work but the vagrant up script still hangs and eventually crashes.
Any help would be much appreciated.
Thanks.

vagrant asks password at only the first time 'vagrant up'

I made my custom vagrant box for CentOS 6.6.
My question is why vagrant always requires password when I 'vagrant up' at only first time.
Here is the console log:
$ vagrant up
Bringing machine 'ns' up with 'virtualbox' provider...
==> ns: Clearing any previously set forwarded ports...
==> ns: Clearing any previously set network interfaces...
==> ns: Preparing network interfaces based on configuration...
ns: Adapter 1: nat
ns: Adapter 2: hostonly
==> ns: Forwarding ports...
ns: 22 => 2222 (adapter 1)
==> ns: Running 'pre-boot' VM customizations...
==> ns: Booting VM...
==> ns: Waiting for machine to boot. This may take a few minutes...
ns: SSH address: 127.0.0.1:2222
ns: SSH username: vagrant
ns: SSH auth method: private key
ns: Warning: Connection timeout. Retrying...
ns: Warning: Connection timeout. Retrying...
ns: Warning: Remote connection disconnect. Retrying...
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
vagrant#127.0.0.1's password:
As you see, vagrant asks password. It continues after I type it. After that, vagrant never ask it whenever I do 'vagrant up'. This occurs at only the first time 'vagrant up'.
I wonder something of my custom box's setting, maybe ssh, is wrong but don't understand where the problem is.
Can anybody guess the possible causes?
Environment:
the version of vagrant is 1.7.2. Host OS is ubuntu 15.04 and Guest OS is CentOS 6.6.
You may also want to try the default vagrant password: vagrant.
Vagrant asks for the password when it can't login automatically. The most obvious reason is that Vagrant does not have the required user key for the user vagrant. Then your entering the correct password and vagrant exchanges the key. Afterwards this does not appear anymore. This key exchange is manager per instance, so if you destroy/delete the instance then next time your ask again to login manually.
Vagrant offers an insecure key on Github and any distributed public available Vagrant box is packaged with it. You can put this key by executing this inside the machine:
wget https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/vagrant/.ssh/authorized_keys
The other way is to use your own private key and configure the Vagrantfile to use the specific key:
Vagrant SSH Config
Vagrant itself will recognize and exchange the insecure key immediately and exchange it for a secure one. Therefore, you have to set this key with Hashicorp Packer.
I entered the password "vagrant" when this happened to me and got right in. See this Vagrant Github issue. Also see this stackoverflow question.

Resources