1
votes

I am new to Vagrant. I am trying to get a suitable developement envirement in order to create a symfony project but for some reason, I can't seem to get this working. What ever machine i build i always get stuck at the "SSH auth method: private key" line.

I made a lot of reading in the past 2 days and this problem seems to happend for various reasons. I tryed everything on satck overflow but just can't seem to pin point what is causing my setup to fail.

I am on my laptop that has windows 10. I have VirtualBox 6.0.8 and Vagrant 2.2.4.

I tryed 4 diffrent boxes including one I builded using Chef and a more generic box that suposidly would work (hashicorp/precise64)

So I am confident the problem is somewhere else that in the vagrantfile.

I have virtualization active in my BIOS ... cheked twice.

I tryed using the git console, the windows cmd with and without admin permission as well as powershell (Just in case) and got the same result.

ssh-config says the following:

Host default
  HostName 127.0.0.1
  User vagrant
  Port 2200
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile "C:/Users/Utilisateur 1/.vagrant.d/insecure_private_key"
  IdentitiesOnly yes
  LogLevel FATAL

I checked inside the VirtualBox gui in the config section and cable box is checked and ports seems to be forwarded 2200 to guest 22 or forwarded 2222 to guest 22 depending on the box I am trying. The farward always matched the ssh-config

also tryed adding the cableconnected1 in the vagrant file even if the box is checked in the gui configuration ...

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

I checked if the insecure_private_key exists at the correct location and it does C:/Users/Utilisateur 1/.vagrant.d/insecure_private_key

I tryed using password authentification instead of ssh key but it froze as well so I turned it back to using ssk key.

I also tryed deleting knowhost file in the .ssh folder but it did nothing

Everytime i tryed something new I used vagrant destroy then vagrant up --provision

I tryed to SSH inside the box while it was stalled ssh [email protected] -p 2200 -i ~/.vagrant.d/insecure_private_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no -o IdentitiesOnly=yes But that gives me ssh_exchange_identification: read: Connection reset by peer

Starting the VM from the VB gui gives me a black screen and stalls at the same place

I uninstalled VirtualBox and Vagrant twice, destroyed and reloaded over 15 times and still get the same error what ever box i use.

So fare I tryed the following boxes hashicorp/precise64 bento/ubuntu-18.04 Homestead And 1 other I deleted and don't remember the name All those baxes are claimed to work.

I tryed adding the port_forward in the vagrantfile because that seemed to have helped other members with the same problem but I ended up with 2 port forwards and still stalled at the same place ...

Heres a log vagrant up --debug &> vagrant.log on my bento/ubuntu-18.04 VM https://transferxl.com/08vvkdTr6YJ5B2

I tryed simplefying my vagrant file to the minimum but that did not help

My vagrant file at the moment looks like this:

Vagrant.configure("2") do |config|
    #berkshelf
    config.berkshelf.enabled = true

    #box
    config.vm.box = 'bento/ubuntu-18.04'
    config.vm.network :private_network, ip: '192.168.33.200'

    #network
    config.vm.network :forwarded_port, guest: 80, host: 8080

    #chef
    chef_repo_path = './chef'

    config.vm.provision :chef_solo do |chef|
        chef.cookbooks_path = 'chef/cookbooks'
        chef.data_bags_path = 'chef/data_bags'
        chef.environments_path = 'chef/environments'
        chef.roles_path = 'chef/roles'

        chef.environment = 'vagrant'
        chef.run_list = [
            'role[webserver]'
        ]
    end

end

-- EDIT

As sugested by Strom in the comments bellow, in case the space in my windows username was the issu, I added the following in vagrant

config.ssh.private_key_path = ["C:/Users/Utilisateur\ 1/.vagrant.d/insecure_private_key"]
config.ssh.insert_key = true

But that returned

vagrant destroy
==> default: Loading Berkshelf datafile...
==> default: Sharing cookbooks with VM
==> default: Running cleanup tasks for 'berkshelf'...
    default: Are you sure you want to destroy the 'default' VM? [y/N] y
There are errors in the configuration of this machine. Please fix
the following errors and try again:

SSH:
* `private_key_path` file must exist: C:/Users/Utilisateur\ 1/.vagrant.d/insecure_private_key

So i changed it to

config.ssh.private_key_path = ["~/.vagrant.d/insecure_private_key"]
config.ssh.insert_key = true

But it did not solve my original problem

3
You need to escape the space in the username: IdentityFile "C:/Users/Utilisateur\ 1/.vagrant.d/insecure_private_key". Please indicate where(VM or Host) each of the files and commands were run. "Connection reset by peer" means the port was 22 not 2200.Strom
Escaping the space cause a syntaxe error on vagrant up so I changed it to ~/.vagrant.d/insecure_private_key and that got passed the error but stalled at the same place. I made an edit in my post with more infoPatrick Simard

3 Answers

1
votes

My solution summary to Vagrant (Homestead) hanging on "SSH auth method: private key":

  1. vagrant box update (for me, to v2.2.5)
  2. vagrant box add laravel/homestead (for me, upgraded homestead to 8.0.1)
  3. VirtualBox GUI: stop Vagrant machine, then "Remove" it and all its files.
  4. vagrant up --provision

Longer explanation

Suddenly and without making any known system changes, SSH on my Vagrant / Homestead box stopped working. Tried many things for a whole day. vagrant up Would freeze on SSH auth method: private key without further errors.

I could not vagrant destroy because the script requires SSH, error: Trigger run failed An error occurred in the underlying SSH library that Vagrant uses So I had to stop and then remove it from the virtualbox GUI.

After above steps 1-4, the vagrant up boot messages gave these more insightful lines:

laravel: Warning: Connection aborted. Retrying...
laravel:
laravel: Vagrant insecure key detected. Vagrant will automatically replace
laravel: this with a newly generated keypair for better security.
laravel:
laravel: Inserting generated public key within guest...
laravel: Removing insecure key from the guest if it's present...
laravel: Key inserted! Disconnecting and reconnecting using new SSH key...

==> laravel: Machine booted and ready!

Although as part of my initial troubleshooting I regenerated the keys, there may have been a problem with them which the new version of Vagrant (with updated net-ssh) may have detected & fixed.

0
votes

After almost 4 days at this, i finally got it working ... My hard drive drop dead so I had to replace it and reinstall windows and all my stuff. First thing I did was try vagrant and virtualbox again. It worked on the first try. I suspect that there was something wrong with VirtualBox and the network (meaning my physical interfaces). Unfortunately, that's all I can say about it since I never got to the bottom of this problem. If like me, you tried everything and you still have the same problem I had, you should take a look at your network. I am not gona tell you to reinstall windows ... that would be insane ... But something somewhere was broken and now everything works as expected. Weird but true!

0
votes

There seems to be an incompatibility problem with Vagrant & the Windows Hypervisor Platform feature in Windows 10

I had this problem and this is how I got get Vagrant & WSL2 working side by side

I have the following environment:

  • Hardware Virtualization enabled in BIOS

  • Windows 10 (Insider Program with Release Preview Channel)

    -- Windows 10 with WSL 2 Version 10.0.19041 Build 19041

  • VirtualBox 6.1.12

    -- Extension Pack Installed

  • Vagrant 2.2.9

These are the settings that worked for me:

  • Windows Hypervisor Platform: Off
  • Virtual Machine Platform: On
  • Windows Subsystem for Linux: On

enter image description here