Laravel Homestead在Mac上SSH认证方法中卡住:私钥

33

我似乎无法使Homestead运行。它在SSH认证方法:私钥处卡住了。

Homestead虚拟机已经启动。我可以打开VirtualBox的终端窗口并使用vagrant:vagrant登录。

我不能使用vagrant ssh、ssh vagrant@127.0.0.1:2204或ssh vagrant@127.0.0.1 -p 2204。

我的文件夹没有显示在虚拟机中,但VirtualBox显示它们已映射。

每次我使用vagrant up,都会出现以下情况:

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.

我已经使用我的密钥替换了Homestead不安全的私钥。许多人会收到“警告:连接超时,正在重试…”,但我没有遇到这种问题。

我使用的是Mac 10.11.6操作系统。

如果有任何帮助,将不胜感激!


你能打开VirtualBox并检查其中的虚拟机状态吗?它是否已经完成启动了? - Frederic Henri
已经启动。我可以打开VirtualBox虚拟机屏幕并登录为vagrant,密码为vagrant。 - Scott O-Town
12个回答

87

今天在 macOS 10.12 上我遇到了同样的问题,花了6个小时来寻找解决方法。最终,在多次重装、重启和试错后,我通过以下步骤解决了问题...

  1. 完全卸载并重新安装 Vagrant、VirtualBox 和 Homestead。
  2. 确保 VirtualBox UI 中的 homestead-7 虚拟机已关闭。
  3. 右键点击 homestead-7 虚拟机,选择“设置”。
  4. 点击“网络”。
  5. 在“适配器1”下,应该连接到NAT,点击“高级”。
  6. 勾选“已连接电缆”旁边的框。
  7. 保存设置,并使用 vagrant up --provision 重新配置 Homestead。
  8. 运行 vagrant reload --provision 重新配置虚拟机。

这就是全部步骤!我在此之后能够通过SSH进行连接,但无法通过浏览器查看Homestead网站(尽管我已经配置了/etc/hosts文件),但是简单的Mac重启似乎解决了这个问题。

由于我不知道这个问题的具体原因,这可能只是我这个案例的一点运气,但请让我知道你的情况如何。


17
步骤三至六解决了我的问题!你是救命恩人@Jack! - schystz
9
步骤3-6对我有暂时解决问题,但每次销毁和重新创建虚拟机都需要进行这些步骤。在我的Homestead目录中更新Vagrantfile是最好的解决方案:https://github.com/mitchellh/vagrant/issues/7648#issuecomment-235282382 - Daniel Sposito
对我来说,在第8步之后,我不需要重新启动我的Mac,但是注意到虚拟机卡在登录界面。我只需要提供默认的用户名和密码(vagrant / vagrant),然后就能访问我的网站了!非常感谢! - schystz
1
我登录只是为了说谢谢!使用laravel 5.4 vagrant 1.9.5 virtualbox 5.1.22。 - Aditya
我也遇到了这个问题,但这促使我更新到最新的VirtualBox,现在一切看起来都很好。实际上,我正在测试Nomad,而不是Homestead。 - Howard M. Lewis Ship
显示剩余2条评论

14
  1. 打开VirtualBox用户界面,进入虚拟机。
  2. 按下回车键使系统继续启动。

然后你就可以看到vagrant up正在进行中。


2
我爱你。这个答案应该被标记为已接受的答案。 - Terry Lin
谢谢,史蒂文。这个回答真的应该标记为被接受的答案。 - undefined

8

我曾经遇到过同样的问题。我在BIOS中启用了VT-x,这解决了我的问题。


Windows 10用户在这里,我也做了同样的事情,它起作用了。 - Julien
我的 BIOS 报告它为“Intel 虚拟化技术”。感谢指点。 - spooky
更换了主板,然后出现了这个问题...对我来说也是如此。谢谢! - mitcheljh

6

Vagrant 2.1.2

vagrant destroy 然后 vagrant up --provision 对我有用。

我注意到,这通常发生在发布新版本的 vagrant 时。


即使这个“解决”了问题,这个漏洞可能会像我的vbox一样重新出现。这是最后的措施,应该提醒。 - Heroselohim
这并不能解决问题,你将不得不重新下载盒子。 - Karim Samir

5

如果您使用的是Windows系统,在尝试完上述方法后仍然无法解决问题,也许这个方法能够帮到您。

以管理员身份打开命令提示符,输入bcdedit命令。您可能会发现hypervisorlaunchtype Auto。如果是这样,请输入bcdedit /set hypervisorlaunchtype off关闭它。重新启动计算机并再次尝试。

希望这可以帮助您。


1
经过三个晚上的故障排除,这最终是我的解决方法。谢谢!!! - Swen

3

对于我来说,这里没有任何有用的东西。我遇到了一个名为“SSH Auth 方法:私钥”的问题,因为我的Mac黑屏并崩溃了。

对我而言有效的方法是执行vagrant destroy然后执行vagrant up --provision。请注意,这当然会影响虚拟机中的所有内容,但您应该始终使用临时原则...


3

在BIOS设置中启用“虚拟化技术”


3

我必须进行fsck操作。(免责声明,我是凭记忆输入的命令)

  1. 打开VirtualBox UI并进入虚拟机。
  2. 如果你看到(initramfs),则输入exit
  3. 运行fsck /dev/mapper/vagrant-vg-root -y
  4. 重新启动

返回到正常终端并尝试:

vagrant halt
vagrant up

从这里开始,对我来说一切都恢复正常了。


1
它对我有效。谢谢,伙计。在我的情况下,我运行fsck /dev/mapper/homestead-vg-root -y。 - dikutandi

1

在使用Homestead v6.4和virtualbox一段时间后,我突然遇到了这个问题。要解决这个问题,请打开VirtualBox(如果使用),并检查日志。

我找到了手动fsck目录的说明,这解决了我的问题。

您的目录可能不同,但我的目录是:

fsck /dev/mapper/homestead--vg-root 

然后选择 y 以修复所有错误。

0
我在安装Docker Desktop for Windows后遇到了这个错误。 两者不兼容。
运行Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Hypervisor 这将禁用hypervisor。
运行Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All 以启用。
我发现现在Homestead需要很长时间才能启动,打开VMBox,选择homestead并点击Show(绿色按钮)。等待直到您看到homestead登录提示。 然后返回,您可以运行vagrant ssh进入Homestead。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接