vagrant up times out on 'default: SSH auth method: private key' when 'VirtualMachinePlatform' Windows Feature is enabled

Created on 22 Oct 2020  路  3Comments  路  Source: hashicorp/vagrant

Vagrant version

Vagrant 2.2.10

Host operating system

Windows 10 Home - Version 20H2 (19042.572)

Guest operating system

laravel/homestead

Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "laravel/homestead"
end

I haven't specified a provider. I have the Virtualbox Version 6.1.16 r140961 (Qt5.6.2)

Debug output

https://gist.github.com/lwpamihiranga/ec3b306a5fa8e400964096d7b476191f

Expected behavior

vagrant up should successfully spin up the box even when the WindowsFeature VirtualMachinePlatform is enabled

Actual behavior

vagrant up times out on default: SSH auth method: private key when the WindowsFeature VirtualMachinePlatform is enabled but it does not timeout(works fine) if I run vagrant up when WindowsFeature VirtualMachinePlatform is disabled

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'laravel/homestead'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'laravel/homestead' version '9.6.1' is up to date...
==> default: Setting the name of the VM: laravel-test-minimum_default_1603343961170_29543
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> 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.

Steps to reproduce

  1. WindowsFeature VirtualMachinePlatform should be enabled. If not enable it by running the following command on PowerShell as Administrator: dism.exe /online /Enable-Feature /FeatureName:VirtualMachinePlatform /all /NoRestart. Then restart the machine
  2. Run vagrant up

References

  • #11931
  • #11890
  • #11741

Note: I have enabled WSL 2 in my machine. The WindowsFeature VirtualMachinePlatform is necessary for WSL 2

Most helpful comment

Hi,
I can reproduce the error and after DISABLING the VirtualMachinePlatform vagrant gets up again... very annoying cause I am working with WSL2, too. Maybe the problem is that WSL2 uses SSH to connect to the Linux Subsystem and so SSH in vagrant does not work?

All 3 comments

Hi,
I can reproduce the error and after DISABLING the VirtualMachinePlatform vagrant gets up again... very annoying cause I am working with WSL2, too. Maybe the problem is that WSL2 uses SSH to connect to the Linux Subsystem and so SSH in vagrant does not work?

I have the same issue. I am using many ubuntu boxes. After installing WSL2 suddenly all boxes stopped working - hang during VM boot at tthe step 'default: SSH auth method: private key'.
I found the suggestion on SO to disable the VirtualMachinePlatform feature and voila - everything automagically works again.

Very annoying, as I definitely want to use WSL side by side with vagrant.

In fact, when the vagrant hangs (and timeouts after that), the machine boots up fine - I can log in to it from VB, but it is not configured for vagrant - SSH auth not setup, so vagrant ssh does nothing. I can even provision it (vagrant up --provision) and execute custom provision scripts. Maybe WSL brings along its own binary for ssh which does not work with vagrant but gets picked up from the PATH?

Can also confirm this issue happened after enabling WSL2 (Ubuntu) and Hyper-V on Windows 10 Home. Only sort-of solution: which only sometimes works is to keep trying vagrant reload. Doesn't always work though :(

Also looks like someone filed a issue in the Microsoft/WSL repo regarding this here https://github.com/microsoft/WSL/issues/4599

Looks like right now you can only have either-or running. I've tried shutting down WSL and/or the distro running and it does not work.


Workaround for now for me was to disable the VirtualMachinePlatform feature in windows by running:

Disable-WindowsOptionalFeature -Online -FeatureName "VirtualMachinePlatform"

When I need to use Docker, I'll re-enable the feature:

Enable-WindowsOptionalFeature -Online -FeatureName "VirtualMachinePlatform"

Depending on your setup/Windows version, you may need to use DSIM.

Was this page helpful?
0 / 5 - 0 ratings