我观看了很多关于Vagrant的视频,看起来非常简单:只要安装VirtualBox和Vargant,然后在Vagrantfile中指定虚拟机名称,运行$ 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管理器并打开新安装的虚拟机,我可以使用“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上列出的所有方法,但没有看到任何人遇到这个问题的视频,他们只是运行vagrant,然后一切正常...
编辑:我在Windows Server上尝试过,它可以完美地开箱即用。所以这很可能是与Windows 10或其他相关的问题。