Vagrant up挂起"ssh auth方法:私钥"

L. *_*brk 17 ssh vagrant

我一直有一些问题让vagrant版本1.8.1与virtualbox 5.0.10一起运行,盒子精确64.我的操作系统是Windows 7.

基本上,当我跑

vagrant up
Run Code Online (Sandbox Code Playgroud)

...... 这发生了

到目前为止,我尝试过以下方面:

打开另一个命令行并运行无数不同的代码,包括:

vagrant ssh
vagrant ssh-config
ssh 127.0.0.1 
Run Code Online (Sandbox Code Playgroud)

我也试过这个视频上显示的修复(无济于事)

https://www.youtube.com/watch?v=vDQpfb0eFTc

以及手动指定ssh密钥和更改ssh密钥.

我尝试手动ssh到框中会遇到"连接被拒绝"错误.

当我通过virtualbox打开VM GUI时,它会在登录页面停止,而不是其他人报告的启动菜单.

我的vagrantfile是未经修改的,但是我尝试了以上所有增加的内容:

config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
Run Code Online (Sandbox Code Playgroud)

..哪个不起作用

我也尝试添加这个(有和没有上面的Vagrantfile添加)

config.ssh.private_key_path = "C:/Users/Luka/.vagrant.d/insecure_private_key"
Run Code Online (Sandbox Code Playgroud)

哪个也没给我什么.

小智 9

我知道这是一个老话题,但我遇到了同样的问题,对我而言,解决方案是在BIOS(VT-x)中启用硬件虚拟化,这是Windows操作系统上运行任何类型的虚拟机所必需的.

我希望这会帮助那些偶然发现这一点的人.


小智 7

我花了几个小时试图解决这个问题,并尝试了上面列出的每个解决方案以及更多,但我没有取得任何进展。

我运行时遇到的错误vagrant up

[...]
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.
[...]
Run Code Online (Sandbox Code Playgroud)

我决定追踪我在正在运行的虚拟机的 VirtualBox 日志中看到的这个事件:

00:00:01.752390 HM: HMR3Init: Attempting fall back to NEM: VT-x is not available
Run Code Online (Sandbox Code Playgroud)

当我看到这一点时,我决定使用“英特尔处理器识别实用程序”(来自英特尔网站)来验证 VT-x 是否已启用。令我惊讶的是,它显示“Intel虚拟化技术”被禁用:

在此输入图像描述

我非常确定 VT-x 在我的 BIOS 中已启用,但我再次检查以确保确定。事实上,VT-x 在我的 BIOS 中已启用。

我对所看到的感到非常困惑,我一直在互联网上查找为什么 VT-x 在 BIOS 中启用,但在操作系统中显示为禁用。许多文章一直指出“Hyper-V”是罪魁祸首。因此,我使用 Windows 功能实用程序 [以及我的 Docker 桌面”卸载了“Hyper-V”,因为它依赖于 Hyper-V 来运行],但 Intel CPU 识别实用程序始终显示 VT-x 为禁用状态。

我尝试的下一步是删除 Windows 10“Windows 功能”中所有被标识为“干扰”Hyper-V 的项目[在搜索栏中列为“打开或关闭 Windows 功能”]。红色的项目是我删除的项目:

  1. 集装箱
  2. 超V
  3. 虚拟机平台
  4. Windows 管理程序平台
  5. Linux 的 Windows 子系统

在此输入图像描述

我重新启动了电脑,再次使用 CPU 识别实用程序检查了 VT-x 的状态,但它仍然被禁用。

此时我几乎打算放弃这个问题,直到我发现一些文章,其中有人在提升的命令提示符(cmd.exe)中手动运行此命令:

dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
Run Code Online (Sandbox Code Playgroud)

我重新启动了电脑,使用 CPU 识别实用程序检查了 VT-x 的状态,令我惊讶的是它显示为“已启用”!!:

在此输入图像描述

当我在 VT-x 显示为已启用后从正在运行的虚拟机检查 VirtualBox 日志时,我可以看到以下事件:

00:00:01.556258 HM: HMR3Init: VT-x w/ nested paging and unrestricted guest execution hw support
Run Code Online (Sandbox Code Playgroud)

在我的命令行窗口中,之后vagrant up,我现在可以看到:

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:
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...
default: Machine booted and ready!
Run Code Online (Sandbox Code Playgroud)

简而言之,我的解决方案?

确保操作系统使用诸如“英特尔处理器识别实用程序”[或取决于您的 CPU 架构的任何实用程序] 等实用程序将 VT-x 视为已启用。我相信 Windows 10 中存在导致此问题的错误,但我无法具体说明(而且我没有时间这样做)。看来 Hyper-V 是所有问题的根本原因。对于担心无法再使用 Docker Desktop 的人们,我相信有非 Hyper-V 解决方案的替代方案(即免费的 Docker EE??)。

祝你好运。