我的流浪汉昨晚工作得很好。我刚打开电脑,点击《流浪者》,这就是我得到的:

==> 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 => 2222 (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
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...

有人吃过这个吗?vagrant在网络上还没有被广泛报道,我也找不到发生这种情况的原因。


当前回答

我通过在/etc/fstab中添加一个新条目来测试我的vagrant VM中挂载的文件夹。后来我注销了,跑了个流浪汉,但当我跑了个流浪汉,我得到:

SSH auth method: private key
Warning: Remote connection disconnect. Retrying...

I read all these posts and tried all the ones that seemed relevant for my case (except for vagrant destroy, which would have certainly fixed my problem, but was a last resort in my case). The post by @Kiee gave me the idea to try to boot my VM directly from the VirtualBox GUI. During the boot process the VM halted itself and was asking me if I wanted to skip mounting the test folder that I had added earlier to /etc/fstab. (That's why vagrant couldn't boot the VM.) After answering 'NO' the VM booted no problem. I logged in, removed the naughty line from my fstab, and shutdown the VM.

在那之后,流浪汉就能很好地踢足球了。

外卖吗?如果突然间vagrant无法引导回您的VM,请尝试直接从提供商引导(在我的情况下是VirtualBox)。您的引导可能挂起了与SSH完全无关的东西。

其他回答

我解决这个问题的方法在这篇文章中没有提到,所以我把细节贴在这里,以防它能帮助到其他人。

造成这种情况的原因是,在机器启动后,流浪汉无法登录机器。造成这种情况的原因有很多,正如本文中提到的,比如机器无法一直启动,或者iptables防火墙阻止SSH。

在我的例子中,问题是我无意中设置了一个“private_network”,它的IP地址与内置的VirtualBox NAT网络(在我的例子中是10.0.2.0/24)在同一个子网中。这打乱了机器的NAT网络(但没有任何地方显示错误),由于vagrant通过NAT网络连接,因此即使机器正在运行且没有启用防火墙,它也无法连接。

Vagrant.configure("2") do |config|
  config.vm.network "private_network", ip: "10.0.2.31"
end

解决办法是更新我的VagrantFile,并使用一个与VirtualBox的NAT网络不冲突的“private_network”IP。

Vagrant.configure("2") do |config|
  config.vm.network "private_network", ip: "10.0.4.31"
end

这是流浪者的新“特征”。看看这里: https://github.com/mitchellh/vagrant/issues/3329

他们将把“错误”改为“警告”。它只是告诉你机器还没有启动,它正在尝试连接…

对我来说,这是流浪者和虚拟盒子之间的兼容性。

我在windows 10上,我所做的就是卸载流浪者和虚拟盒子

然后安装一个旧版本的虚拟盒子,特别是4.3.38版本(也为这个版本安装扩展包)

然后安装最新版本的vagrant(目前1.8.5)

从那以后,它起作用了。

也许这是一个太简单的答案,以帮助许多人,但值得一试,如果你没有:做一个“流浪者暂停”,而不是“流浪者暂停”,然后重新启动VM与“流浪者up”。

我认为我的问题是由于一些“kworker”进程出现bug,并且在VM中不断超时,所以做硬重启似乎正确地重新加载进程,而保存和恢复只是在其破碎状态下恢复破碎的进程。

删除文件:

C:\Users\UserName\\.vagrant.d\insecure_private_key

然后运行:

vagrant up