无法通过SSH连接到vagrant的Ubuntu 16.04?

3

我创建了一个非常简单的Vagrantfile文件:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.box = "boxcutter/ubuntu1604"
  config.vm.hostname = "r1"
  config.vm.network "forwarded_port", guest: 3000, host: 3000

  config.vm.network "private_network", ip: "192.168.50.10"

  config.vm.provider "virtualbox" do |vb|
     vb.memory = "1024"
  end

end

升级Ubuntu 16.04服务器的目的是为了更好的使用,但是SSH连接存在问题。

我的日志:

vagrant up

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'boxcutter/ubuntu1604' is up to date...
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> 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: 3000 (guest) => 3000 (host) (adapter 1)
    default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2200
    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.

...

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.

我将 config.vm.box = "boxcutter/ubuntu1604" 替换为盒子名称"ubuntu/trusty64",并且它运行良好,但如何在16.04上解决?


1
请确保您拥有最新的vagrant/virtualbox,旧版本和Ubuntu 16.04存在许多问题。 - Sander Visser
看起来我在 https://atlas.hashicorp.com/boxes/search 找到的 'ubuntu/trusty64' 是桌面版操作系统,而不是服务器版。在安装过程中,我遇到了 'upgrade BIOS or use force_addr=0xaddr' 错误问题,但 Vagrant 没有显示错误。我导入并使用了 - vagrant box add https://atlas.hashicorp.com/gbarbieru/boxes/xenial,它运行良好。希望能帮助到某些人。 - sharp
所以,我通过将以下代码添加到vagrantfile来解决这个问题:vb.customize ["modifyvm", :id, "--cableconnected1", "on"] - sharp
3个回答

1
我曾经遇到同样的问题,通过更新VirtualBox和vagrant版本解决了。尝试使用"bento/ubuntu-16.04" vagrant box。对我而言,"ubuntu/xenial64"无法工作。

0

您尝试过错误提到的解决方案吗?默认情况下,boot_timeout为300秒 [1] - 您是否给了boxcutter box更多时间,例如600秒,以查看其是否会在此后响应?

然而,在ubuntu/trusty64旁边还有ubuntu/xenial64[2],它是16.04版本-也许您想要尝试一下。


我尝试增加超时时间并尝试使用ubuntu/xenial64,正如您所注意到的。但结果仍然相同... - sharp

0
Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/xenial64"
  config.vm.provider :virtualbox do |vb|
  vb.customize ["modifyvm", :id, "--memory", "2048"]
 end    

你可以试试这个,也许会对你有帮助。


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