diff options
author | Denver Abrey <denvera@gmail.com> | 2016-10-13 22:00:33 +0200 |
---|---|---|
committer | Denver Abrey <denvera@gmail.com> | 2016-10-13 22:00:33 +0200 |
commit | 22755169b513ebde33de2704afd2f7a0b366723a (patch) | |
tree | c908300091e4fe08b65ccd1d48f78f84f38f685c | |
parent | 83a81dabdb8e0acb5cec4fdb83417898575d2736 (diff) |
Add key authentication to ssh input
-rw-r--r-- | lib/oxidized/input/ssh.rb | 4 | ||||
-rw-r--r-- | lib/oxidized/node.rb | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/oxidized/input/ssh.rb b/lib/oxidized/input/ssh.rb index c0b7cf9..32f4e40 100644 --- a/lib/oxidized/input/ssh.rb +++ b/lib/oxidized/input/ssh.rb @@ -23,6 +23,7 @@ module Oxidized secure = Oxidized.config.input.ssh.secure @log = File.open(Oxidized::Config::Log + "/#{@node.ip}-ssh", 'w') if Oxidized.config.input.debug? port = vars(:ssh_port) || 22 + keys = node.auth[:private_key].is_a?(Array) ? @node.auth[:private_key] : [@node.auth[:private_key]] if proxy_host = vars(:ssh_proxy) proxy = Net::SSH::Proxy::Command.new("ssh #{proxy_host} -W %h:%p") end @@ -32,7 +33,8 @@ module Oxidized :paranoid => secure, :auth_methods => %w(none publickey password keyboard-interactive), :number_of_password_prompts => 0, - :proxy => proxy + :proxy => proxy, + :keys => keys } ssh_opts[:kex] = vars(:ssh_kex).split(/,\s*/) if vars(:ssh_kex) ssh_opts[:encryption] = vars(:ssh_encryption).split(/,\s*/) if vars(:ssh_encryption) diff --git a/lib/oxidized/node.rb b/lib/oxidized/node.rb index c93a16a..dc44df7 100644 --- a/lib/oxidized/node.rb +++ b/lib/oxidized/node.rb @@ -130,8 +130,9 @@ module Oxidized def resolve_auth opt # Resolve configured username/password { - username: resolve_key(:username, opt), - password: resolve_key(:password, opt), + username: resolve_key(:username, opt), + password: resolve_key(:password, opt), + private_key: resolve_key(:private_key, opt), } end |