From 61466c8e65b476b2d580a0eca06c7512026118c0 Mon Sep 17 00:00:00 2001 From: Markus Perl Date: Sat, 17 Oct 2015 23:00:39 +0200 Subject: [PATCH] #5186: Warning: Authentication failure. Retrying... after packaging box --- plugins/providers/virtualbox/provider.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/providers/virtualbox/provider.rb b/plugins/providers/virtualbox/provider.rb index 969fb4718..b8b88d9ca 100644 --- a/plugins/providers/virtualbox/provider.rb +++ b/plugins/providers/virtualbox/provider.rb @@ -59,12 +59,20 @@ module VagrantPlugins # If the VM is not running that we can't possibly SSH into it return nil if state.id != :running + # If the insecure key was automatically replaced with a newly generated key pair, + # use this key to connect to the machine + private_key_path = nil + if @machine.data_dir.join("private_key").file? + private_key_path = @machine.data_dir.join("private_key") + end + # Return what we know. The host is always "127.0.0.1" because # VirtualBox VMs are always local. The port we try to discover # by reading the forwarded ports. return { host: "127.0.0.1", - port: @driver.ssh_port(@machine.config.ssh.guest_port) + port: @driver.ssh_port(@machine.config.ssh.guest_port), + private_key_path: private_key_path } end