diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index 3c17b4e00..5335f3a27 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -501,7 +501,7 @@ module Vagrant if !info[:private_key_path] && !info[:password] if @config.ssh.private_key_path info[:private_key_path] = @config.ssh.private_key_path - elsif info[:keys_only] + else info[:private_key_path] = @env.default_private_key_path end end diff --git a/test/unit/vagrant/machine_test.rb b/test/unit/vagrant/machine_test.rb index 8f42207d8..6b4dd1531 100644 --- a/test/unit/vagrant/machine_test.rb +++ b/test/unit/vagrant/machine_test.rb @@ -777,6 +777,16 @@ describe Vagrant::Machine do ) end + it "should return the default private key path with keys_only = false" do + provider_ssh_info[:private_key_path] = nil + instance.config.ssh.private_key_path = nil + instance.config.ssh.keys_only = false + + expect(instance.ssh_info[:private_key_path]).to eq( + [instance.env.default_private_key_path.to_s] + ) + end + it "should not set any default private keys if a password is specified" do provider_ssh_info[:private_key_path] = nil instance.config.ssh.private_key_path = nil