我的流浪汉昨晚工作得很好。我刚打开电脑,点击《流浪者》,这就是我得到的:
==> 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
这里有很多很好的答案,我不能全部读完,但是,我只是来给我的一点贡献。我有两个不同的问题:
vagrant up wasn't able to find my ssh 'id_rsa' (because I didn't have it yet, at that time):
I ran ssh-keygen -t rsa -b 4096 -C "myemailaddress@mydomain.com", based on this GitHub's article, and voilá, steped through that;
Then, I got the same problem of this question "Warning: Connection timed out. Retrying...", eternally...:
So, after reading a lot, I've restarted my system and looked at my BIOS (F2 to get there, on PC), and there were Virtualization disabled. I've enabled that, saved, and started the system once again, to check if it has changed anything.
从那以后,流浪起来就像有魔力一样!现在是凌晨4点,但它还在跑!多酷啊,hã?我知道很少有像我这样的受虐狂开发者会在Windows上尝试这个,特别是在Windows 10上,我只是无法不忘记来这里并留下我的话…另一个重要的信息,是,我试图设置Laravel 5,使用Homestead, VirtualBox,作曲家等。这是有效的。所以,希望这个答案能对你有所帮助,就像这个问题和答案对我有所帮助一样。祝福你。G-bye !
关闭虚拟机内部的iptables防火墙
我是这样解决的:
我在我的Vagrantfile中启用了GUI界面(这是配置文件)
我可以在Gui中使用标准用户名vagrant和密码vagrant登录运行中的虚拟机
我关闭了虚拟机内部运行的iptables防火墙
这解决了我的问题,我发现,防火墙阻止了来自本地网络的所有ip,如192.168.x。X和10.x.x.x
添加/etc/iptables规则。D /199-allow-wan允许wan的所有连接:
ip46tables -A wan-input -j ACCEPT
(ip46tables是一个别名)在我的Vagrant例子Freifunk社区中看到这个提交