VirtualBox 6.0.8, Vagrant 2.2.4 Hangs on SSH auth method: private key

3,165 views
Skip to first unread message

Patrick Simard

unread,
May 24, 2019, 12:25:51 PM5/24/19
to Vagrant
Hey guys!
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 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.

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

also tryed adding it manualy

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

the insecure_private_key exists at the correct location

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
hashicorp/precise64
bento/ubuntu-18.04
And 2 others I deleted and don't remember the names

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 
ATTACHED to this message

My vagrant file 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


vagrant.log

Dennis Chang

unread,
May 24, 2019, 3:10:31 PM5/24/19
to Vagrant
What happens when you delete all the chef stuff from your Vagrantfile?
Will it boot up?

Patrick Simard

unread,
May 24, 2019, 3:45:57 PM5/24/19
to Vagrant
no. Like i said, I tryed diffrent boxes. Even one with minimal vagrant setup and always end up at the same place. 

Dennis Chang

unread,
May 24, 2019, 3:48:54 PM5/24/19
to Vagrant
I would uninstall Virtualbox and re-install it (and possibly Vagrant as well). If a simple Vagrantfile won't spin up a machine for you, then you have a deeper issue.

Patrick Simard

unread,
May 24, 2019, 4:40:55 PM5/24/19
to Vagrant
lol Thanks for your help Dennis, I said in my main post that I uninstalled VirtualBox and Vagrant twice. 

I have been at this for 2 days now and tryed pretty much everything posted in stack overflow ... I just don't get it ... I also deleted my Anti virus a a lot of other apps while i was at it, just in case of of them could prevent the SSH communication. I am able to SSH to a real server thought. Also my git works fine on my other projects so port 22 is not an issue. Do I need to do something in my router about port 2222? ... 

Dennis Chang

unread,
May 24, 2019, 5:10:30 PM5/24/19
to Vagrant
Hi Patrick,

Really sorry that I didn't read your entire message fully. It's a long message. Lol.

So, what I can suggest is, if you can SSH to remote hosts.
Then try to SSH to the Virtualbox machine.

So for instance, when the machine is coming up, you'll notice a host port number, as you mentioned, port 2222.
So you should be able to reach the VM with the command:

ssh -i insecure_private_key -P 2222 vag...@127.0.0.1

See if you already have the SSH host key stored in ~/.ssh/known_hosts. I presume you're using PuTTy so it will be a known_hosts somewhere in PuTTy.
If it's already there, maybe delete it. Try to establish the connection again, it should prompt you to save the host key again. Say yes and it should attempt
to login. If it fails login (you'll need to check the private_key you're using).

ssh -vvv -i insecure_private_key -P 2222 vag...@127.0.0.1

will produce output for your attempt to login. Post the output here. If you get a password prompt, the password for vagrant boxes is "vagrant".

Dennis

Dennis Chang

unread,
May 24, 2019, 5:16:51 PM5/24/19
to Vagrant
P.s. I'm assuming that you are running vagrant and virtualbo xon your local laptop or desktop.
It should have nothing to do with your router, unless you are trying to establish an SSH connection from a remote host?
In that case, it gets more complicated.

However, because it's a Windows host, I'm guessing that when you try to SSH to the Vagrant machine (Virtualbox machine)
that Windows prompts you to allow or block the attempted connection? If you're not sure, perhaps you can try and disable the
local firewall on your laptop? You mentioned Anti-virus, it's possible, it's a firewall as well (so keep it off as well). The local
firewall on Windows is called Defender I believe.


Patrick Simard

unread,
May 24, 2019, 5:53:44 PM5/24/19
to Vagrant
I did get a popup to authorise the connection. And i did but let me try turning it off completly. In the mean time, i did a vagrant up on one console, and started a new one when it got stuck. This is the output:

Utilisateur 1@PSIMARD-CLIIIC MINGW64 /c/dev/compte/compte (master)
$ vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile "C:/Users/Utilisateur 1/.vagrant.d/insecure_private_key"
  IdentitiesOnly yes
  LogLevel FATAL


$ ssh -vvv -i ~/.vagrant.d/insecure_private_key -P 2222 vag...@127.0.0.1
OpenSSH_7.9p1, OpenSSL 1.1.1a  20 Nov 2018
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolve_canonicalize: hostname 2222 is address
debug2: resolve_canonicalize: canonicalised address "2222" => "0.0.8.174"
debug2: ssh_connect_direct
debug1: Connecting to 0.0.8.174 [0.0.8.174] port 22.
debug1: connect to address 0.0.8.174 port 22: Network is unreachable
ssh: connect to host 0.0.8.174 port 22: Network is unreachable

Where does 0.0.8.174 come from?

Patrick Simard

unread,
May 24, 2019, 5:56:36 PM5/24/19
to Vagrant
I got the same result with windows defender off :-(

Dennis Chang

unread,
May 24, 2019, 5:58:53 PM5/24/19
to Vagrant
Double-check my syntax, it could be a small p instead of a big P.

But if that's not the issue, my guess is, you have a 2222 stored in a hosts file.
Check \Windows\system32\devices\

for a file named host. Could there be a record in there with the name 2222 that points to 0.0.8.174?

I think it's the small p vs big P. Try it again,

ssh -vvv -i ~/.vagrant.d/insecure_private_key -p 2222 vag...@127.0.0.1

Dennis

Patrick Simard

unread,
May 24, 2019, 6:53:31 PM5/24/19
to Vagrant
I asome you mean
C:\Windows\System32\drivers\etc\host ?

There was nothing in there that could mess with vagrant but just to be sure, i commented everything and tryed again with -p and a few other params

Utilisateur 1@PSIMARD-CLIIIC MINGW64 /c/dev/symphony 4/gardening (master)
$ vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile "C:/Users/Utilisateur 1/.vagrant.d/insecure_private_key"
  IdentitiesOnly yes
  LogLevel FATAL
  ForwardAgent yes


$ ssh -vvv vag...@127.0.0.1 -p 2222 -i ~/.vagrant.d/insecure_private_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no -o IdentitiesOnly=yes

OpenSSH_7.9p1, OpenSSL 1.1.1a  20 Nov 2018
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolve_canonicalize: hostname 127.0.0.1 is address
debug2: ssh_connect_direct
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 2222.
debug1: Connection established.
debug1: identity file /c/Users/Utilisateur 1/.vagrant.d/insecure_private_key type -1
debug1: identity file /c/Users/Utilisateur 1/.vagrant.d/insecure_private_key-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
ssh_exchange_identification: read: Connection reset by peer

Dennis Chang

unread,
May 24, 2019, 7:40:21 PM5/24/19
to Vagrant
It looks like you're getting somewhere! The connection reset by peer is you trying to establish a connection. That's good.

I would suggest you access the console through VirtualBox and get a prompt.
Remember, vagrant:vagrant (is the username/password).

And then maybe restart SSH service. At this point, you'll need to observe logs to see why it's resetting.
You can check to see if the SSH process is tied to a particular interface? You can check with the command

(on Linux)
netstat -tlpn | grep 22

It *should* be bound to any port, i..e 0.0.0.0/22.

Oh, another thing, sometimes, permissions on the private_key can prevent connection.

If the private_key is a DSA key, then the new OpenSSH rejects these keys.
You may want to access /etc/ssh/sshd_config and review the configuration for SSH.

One more thing, 'vagrant ssh' still fails?

Dennis
P.s. Another thought, sorry I'm mostly guessing here, perhaps when you spun up the machine, you asked vagrant to generate a new SSH key?
If your vagrant file doesn't have any ssh configurations then it should use the insecure_private_key.

Patrick Simard

unread,
May 25, 2019, 12:54:04 PM5/25/19
to Vagrant
Hey Dennis,
thanks for your help.
I just made a screen video here: https://screencast-o-matic.com/watch/cqhTDATocW

I hope there's something in there that can help you understand whats going on.

Dennis Chang

unread,
May 25, 2019, 1:53:01 PM5/25/19
to Vagrant
Hi Patrick,

So I'm watching your video (thanks for that) and the black screen through the console is disconcerting.
I've seen that before, in my case, it was some effect from a boot script (/etc/rc.local) that
we had in our environment. I didn't really fix it except for removing the entire boot script
from the process.

In your case, my first suspicion are the custom boot configuration option that you have
in your Vagrantfile. If you will, can you post it? This is the Vagrantfile for (ytake/gardening).

So I'm download this vagrant box myself (2.7 GB) and I'll poke around to see what is in
there that may affect the boot console screen.

But in the meantime, I'd like you to try and get output from the boot screen. Recall,
there was a screen to select a Linux version. You mentioned you selected recovery
option? Well instead of selecting that second option, hit ESC instead. This should
output the options (I'd like to see it). Notice in the output of the options, there is a "quiet"
someplace. I'd like you to edit that line, by pressing 'E' and remove "quiet". Finally,
when you hit Enter, the boot process should show Linux boot text. We want to see where
it dies.

What I believe is happening is, for the black screen, something is affecting the console.
However, given all the problems you're experiencing with Vagrant and VirtualBox (has it
*ever* worked for you on this machine?) I suspect that there is something wrong with
VirtualBox and the network (meaning your physical interfaces). Because all VMs will use
the network, I'm guessing there may be an issue with VirtualBox and the network interfaces
on your computer. So for instance, when you have "private_network" in your Vagrantfile,
you *should* see a virtual interface (under Windows Network Connections). That's what
happens on my laptop (but I use a Mac, but it's the same principle).

Perhaps you can display your network connections?

The idea is that since, a VM needs to establish the network interface inside Vagrant/VirtualBox,
this is where it is failing. A VM OS will at times stall, indefinitely while trying to obtain an IP
address, for instance, from a DHCP server. So in other words, if your laptop/desktop has network
issues then it's possible it will affect VirtualBox.

So let's start there. If you can show us Vagrantfile, your network connections, and finally
if you can play with the boot options so that it displays a Linux boot sequence then we can
track down your issue.

Dennis

Patrick Simard

unread,
May 26, 2019, 9:09:00 PM5/26/19
to Vagrant
Hey Dennis, sorry for the late reply. My laptop's hardrive drop dead on me ... So I upgraded to a SSD and just finished reinstalling all my stuff. The good news is vagrant and virtualbox both work now. I suspect you where right on your last message. It was probably a mess in my network with all the different environments I had running. Starting over on a fresh windows did the trick. I wish we could of got to the bottom this but at least it works now. Thanks a lot for your support ;-) 

Dennis Chang

unread,
May 27, 2019, 9:15:44 AM5/27/19
to Vagrant
I guess replacing your hard drive did the trick. :)
Reply all
Reply to author
Forward
0 new messages