(#12884) Use default ssh.private_key_path when ssh.keys_only = false

This commit is contained in:
William Bradford Clark 2022-09-10 01:56:22 -04:00
parent 241810b28a
commit 15df2c69b4
2 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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