Hello, guys. Have you ever encountered any strange issues when booting your VM using Vagrant? In my case, when I execute vagrant up to boot my VM, it takes an extremely long time and hangs at ssh auth method: private key.

The console messages look like this:

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> 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: 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

And then it gets stuck.

After spending hours researching this issue, I ended up found solutions to to this kind of issue.

Below are the solutions that may solve this problem. You can try one of them, or all of them, until the problem is resolved.

Solutions

Increase timeout

Add this line to your Vagrantfile:

config.vm.boot_timeout = 300

Check network setting

Ensure that your VM has the Cable Connected setting enabled. You can find this setting in the Network tab of the VirtualBox GUI.

Virtualbox - Cable Connected

Alternatively, add the following line to your Vagrantfile to enable Cable Connected:

config.vm.provider "virtualbox" do |vb|
    vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
end

Disable Hyper-V

  • Windows Users Only

Hyper-V is a Windows server virtualization tool that creates virtual machines on x86-64 systems running Windows. It cannot run concurrently with VirtualBox, so you need to disable it.

First, find Turn Windows features on or off.

Navigate to Control Panel -> Programs, and under the Programs and Features section, click the link as shown in the screenshot below.

Turn Windows fetures on or off

Now, make sure that "Windows Hypervisor Platform" is unchecked. Also, ensure "Virtual Machine Platform" is checked.

Turn off Hyper-v

Windows Hyperviosr Platform: Unchecked
Virtual Machine Platform: Checked

Click the OK button and then reboot.

Check BIOS setting

Enable the hardware virtualization in BIOS (VT-x), which is required on Windows OS to run any kind of virtual machine.

Click on VM Preview

Open the VirtualBox UI for the VM you are running. The screenshot may look like this:

Virtualbox GUI

If the GUI is not displayed, add gui = true in the Vagrantfile and try again:

config.vm.provider "virtualbox" do |v|
  v.gui = true
end

Click on the Preview window and press the Enter key to allow the system to continue booting. You should then see the vagrant up command proceeding.

Bug for bionic64

If you are using the ubuntu/bionic64 box and experiencing the same problem, there is a confirmed bug that causes some of the newer Ubuntu boxes to boot slowly, leading to an SSH timeout. Adding the following settings to your Vagrantfile may help:

config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"]
    vb.customize ["modifyvm", :id, "--uartmode1", "file", File::NULL]
end

Conclusion

Hope this post helps and saves your time 🙂

Last modified: June 19, 2023

Author

Comments

Hi Terry, thanks for creating this post as I was having problems with vagrant starting. I read your blurb about you and thought I would help to correct some grammar mistakes and make it sound better. Below is what I came up with I am a self-taught programmer since 2007. In my early career (before 2007), I did a variety of different jobs such as graphic design, stockbroker, real-estate agent, and even sold fried chicken at a night market. After many years, I finally found my true passion in the programming world.

Nestor Villalobos 

After a couple of days of trying to solve the problem with “SSH auth method: private key”, it was found that windows 10 has a conflict with vagrant. As a tool to validate the status of virtualization, the program was used: “https://www.intel.com/content/www/us/en/download/12136/28539/intel-processor-identification-utility-windows-version .html ” I show you the capture of the initial state: https://i.imgur.com/hidKDRN.png Fix it by disabling the following windows features: https://i.imgur.com/ZzjryTA.png Once the aforementioned features were deactivated and the computer was restarted, I share the new state of the processor where it is evident that virtualization is already working: https://i.imgur.com/IVzh4YR.png PS: On saying that you already activate virtualization on the board (bios) With this solution already vagrant works perfectly for me.

Adding config.vm.boot_timeout = 300 to the Vagrantfile worked for me. I didn’t have to change any settings in VirtualBox. Do you have any idea how to reduce its boot time so as not to require config.vm.boot_timeout in the vagrant file?

Thanks for help. Trully appreciate 🙂

Write a Reply or Comment

Your email address will not be published.