Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[OHAI-402] Fixes ssh keypairs on EL systems #131

Closed
wants to merge 2 commits into from

3 participants

@dcondomitti

OHAI-402 broke EL systems where sshd_config is present but doesn't contain HostKey entries (the default template.) This changes the conditional so ohai falls back to the known default paths for ssh_host_rsa_key and ssh_host_dsa_key when sshd_config is found.

@btm btm closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 15, 2013
  1. @dcondomitti

    Test that EL systems with commented out HostKeys (default) fall back …

    dcondomitti authored dcondomitti committed
    …to key paths.
  2. @dcondomitti

    Fall back to ssh keypair paths if sshd_config is found but doesn't sp…

    dcondomitti authored dcondomitti committed
    …ecify keys.
This page is out of date. Refresh to see the latest.
View
5 lib/ohai/plugins/ssh_host_key.rb
@@ -52,7 +52,10 @@ def is_dsa_or_rsa?(file)
end
end
end
-else
+end
+
+# Fall back to looking at files directly if sshd_config yields no valid keys.
+if keys[:ssh].empty?
if keys[:ssh][:host_dsa_public].nil? && File.exists?("/etc/ssh/ssh_host_dsa_key.pub")
keys[:ssh][:host_dsa_public] = IO.read("/etc/ssh/ssh_host_dsa_key.pub").split[1]
end
View
14 spec/unit/plugins/ssh_host_keys_spec.rb
@@ -74,4 +74,18 @@
it_behaves_like "loads keys"
end
+
+ context "when an sshd_config is found but does not contain valid keys" do
+ before do
+ sshd_config_file_without_keys =<<EOS
+# HostKeys for protocol version 2
+#HostKey /etc/ssh/ssh_host_rsa_key
+#HostKey /etc/ssh/ssh_host_dsa_key
+EOS
+ File.stub(:open).with("/etc/ssh/sshd_config").and_yield(sshd_config_file_without_keys)
+ File.stub(:exists?).and_return(true)
+ end
+
+ it_behaves_like "loads keys"
+ end
end
Something went wrong with that request. Please try again.