Windows上的Vagrant不能流浪和ssh连接

时间:2016-07-10 17:16:40

标签: vagrant vagrantfile vagrant-windows

所以我在Vagrant上观看了很多视频,看起来很简单:安装了VirtualBox和Vargant,只需在Vagrantfile中指定VM框的名称,运行$ vagrant up你应该可以直接$ vagrant ssh到它。

然而,在一个星期结束之后,以及许多头疼/破坏键盘后,这仍然无效。

PS C:\dev\web> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/trusty32'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty32' is up to date...
==> default: Setting the name of the VM: web_default_1468168716511_77856
==> default: Clearing any previously set forwarded ports...
==> 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 (guest) => 2222 (host) (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
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 you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

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.

同时,如果我打开VirtualBox Manager并打开新安装的Box,我可以使用'vargant'作为用户名和密码完全连接到它,我可以看到它上面没有安装任何内容。我不能通过PuTTY或Cygwin ssh。

执行$ vagrant ssh-config输出以下内容:

PS C:\dev\web> vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile C:/Users/User/.vagrant.d/insecure_private_key
  IdentitiesOnly yes
  LogLevel FATAL

我的Vagrantfile:

Vagrant.configure("2") do |config|

  config.vm.box = "ubuntu/trusty32"

   config.vm.provider "virtualbox" do |vb|

     vb.gui = true

   end

   config.vm.provision "shell", inline: <<-SHELL
     apt-get update
     apt-get install -y apache2
   SHELL
end

我已经尝试过在serverfault和stackoverflow上列出的所有内容,我没有看到任何人们有这个问题的视频,他们所做的只是运行流浪汉,它只是工作......

编辑:我在Windows服务器上尝试过此操作,它开箱即用。所以这很可能是与Windows 10或其他相关的问题。

1 个答案:

答案 0 :(得分:0)

我今天遇到了一个非常类似的问题,我开始与你的环境略有不同(Cent OS 7),但安装VirtualBox Guest Additions可能有所帮助。命令vagrant plugin install vagrant-vbguest 应该做的。

页面where I found this确实有其他相关信息,这可能有所帮助。