Merge pull request #12885 from wbclark/12884_keys_only_fix

(#12884) Use default ssh.private_key_path when ssh.keys_only = false
This commit is contained in:
Chris Roberts 2022-09-21 13:21:27 -07:00 committed by GitHub
commit c13c0feabf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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