diff --git a/lib/inspec/resources/ssh_config.rb b/lib/inspec/resources/ssh_config.rb index e0236b0b7..d2e2a0f66 100644 --- a/lib/inspec/resources/ssh_config.rb +++ b/lib/inspec/resources/ssh_config.rb @@ -39,7 +39,7 @@ module Inspec::Resources def convert_hash(hash) new_hash = {} hash.each do |k, v| - new_hash[k.downcase] = v + new_hash[k.downcase] ||= v end new_hash end diff --git a/test/fixtures/files/ssh_config b/test/fixtures/files/ssh_config index c9a4b208c..1107d2f1e 100644 --- a/test/fixtures/files/ssh_config +++ b/test/fixtures/files/ssh_config @@ -4,3 +4,6 @@ Host * SendEnv LANG LC_* HashKnownHosts yes GSSAPIAuthentication no + HostBasedAuthentication yes + HostbasedAuthentication no + HostbasedAuthentication no diff --git a/test/unit/resources/ssh_conf_test.rb b/test/unit/resources/ssh_conf_test.rb index 3f4f43af3..7a0c4369e 100644 --- a/test/unit/resources/ssh_conf_test.rb +++ b/test/unit/resources/ssh_conf_test.rb @@ -18,6 +18,11 @@ describe "Inspec::Resources::SshConfig" do _(resource.gssapiauthentication).must_equal "no" _(resource.GSSAPIAuthentication).must_equal "no" end + + it "uses the first value encountered" do + resource = load_resource("ssh_config") + _(resource.HostBasedAuthentication).must_equal "yes" + end end describe "sshd_config" do