我的一个 Vagrant 盒子最终处于“已中止”状态,显然是我内存不足或类似原因,是的。现在盒子无法正常启动。
以下是我得到的结果:
$ vagrant up cloud2
Bringing machine 'cloud2' up with 'virtualbox' provider...
[cloud2] Clearing any previously set forwarded ports...
[cloud2] Fixed port collision for 22 => 2222. Now on port 2200.
[cloud2] Clearing any previously set network interfaces...
[cloud2] Preparing network interfaces based on configuration...
[cloud2] Forwarding ports...
[cloud2] -- 22 => 2200 (adapter 1)
[cloud2] Booting VM...
[cloud2] Waiting for machine to boot. This may take a few minutes...
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. This can
mean a number of things.
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.
$
它说它正在运行,但是我无法登录。
$ vagrant status cloud2
Current machine states:
cloud2 running (virtualbox)
The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.
$ vagrant ssh cloud2
ssh_exchange_identification: read: Connection reset by peer
$
这是该盒子的 Vagrantfile 配置:
config.vm.define "cloud2" do |cloud2|
cloud2.vm.box = "precise32"
cloud2.vm.network "public_network", :bridge => 'wlan0'
config.vm.boot_timeout = 600
# config.vm.provider :virtualbox do |vb|
# vb.customize ["modifyvm", :id, "--memory", "1024"]
# vb.customize ["modifyvm", :id, "--cpus", "2"]
# end
end
我在阅读这里的一些帖子时将超时时间设置为 600,但这对我没有任何帮助。
SOS!我在那台虚拟机上做了很多事情,但我……没有备份 :D :P
答案1
答案2
执行命令
vagrant ssh-config
在输出中,请检查
IdentityFile /home/{USERNAME}/.vagrant.d/insecure_private_key
并切换
ssh user {USERNAME}
最后,运行
vagrant up
答案3
/etc/ssh/sshd_config
当虚拟机内部无效但 ssh 服务已重新启动时,也可能会发生这种情况。
无效示例/etc/ssh/sshd_config
:
# Package generated configuration file
# See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for
Port 22
...
UsePAM yesAcceptEnv GIT_*
当您的配置脚本执行此操作或您手动更改某些内容时,可能会出现这种情况。
更改vb.gui = true
您的Vagrantfile
并启动您的虚拟机(vagrant up
)以调试此问题。/etc/ssh/sshd_config
生效后重新启动您的 ssh 服务:
service ssh restart
答案4
我收到了同样的错误消息。问题出在不属于我而是属于 root 用户的 ssh 密钥上。
sudo chown {USERNAME} /home/{USERNAME}/.vagrant.d/insecure_private_key
现在一切正常!