From c5a76961823fe108c2b84c6701f9cb9064187d63 Mon Sep 17 00:00:00 2001 From: Christian Eichhorn Date: Sat, 28 Apr 2018 01:43:37 +0200 Subject: [PATCH] * Net::SSH * Deprecation warning for :paranoid option fixed --- lib/knife-solo/ssh_command.rb | 11 +++++++++-- test/ssh_command_test.rb | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/knife-solo/ssh_command.rb b/lib/knife-solo/ssh_command.rb index 36b06bbc..b3512ffb 100644 --- a/lib/knife-solo/ssh_command.rb +++ b/lib/knife-solo/ssh_command.rb @@ -1,6 +1,5 @@ module KnifeSolo module SshCommand - def self.load_deps require 'knife-solo/ssh_connection' require 'knife-solo/tools' @@ -8,6 +7,14 @@ def self.load_deps require 'net/ssh/gateway' end + def self.verify_option_key + @verify_option_key ||= if Net::SSH::VALID_OPTIONS.include? :verify_host_key + :verify_host_key + else + :paranoid + end + end + def self.included(other) other.class_eval do # Lazy load our dependencies if the including class did not call @@ -171,7 +178,7 @@ def connection_options options[:gateway] = config[:ssh_gateway] if config[:ssh_gateway] options[:forward_agent] = true if config[:forward_agent] if !config[:host_key_verify] - options[:paranoid] = false + options[KnifeSolo::SshCommand.verify_option_key] = false options[:user_known_hosts_file] = "/dev/null" end if config[:ssh_keepalive] diff --git a/test/ssh_command_test.rb b/test/ssh_command_test.rb index 57df41db..fc0d444b 100644 --- a/test/ssh_command_test.rb +++ b/test/ssh_command_test.rb @@ -104,7 +104,7 @@ def test_handle_startup_script def test_handle_no_host_key_verify cmd = command("10.0.0.1", "--no-host-key-verify") - assert_equal false, cmd.connection_options[:paranoid] + assert_equal false, cmd.connection_options[KnifeSolo::SshCommand.verify_option_key] assert_equal "/dev/null", cmd.connection_options[:user_known_hosts_file] end @@ -122,7 +122,7 @@ def test_handle_ssh_gateway def test_handle_default_host_key_verify_is_paranoid cmd = command("10.0.0.1") - assert_nil(cmd.connection_options[:paranoid]) # Net:SSH default is :paranoid => true + assert_nil(cmd.connection_options[KnifeSolo::SshCommand.verify_option_key]) # Net:SSH default is (:paranoid or :verify_host_key) => true assert_nil(cmd.connection_options[:user_known_hosts_file]) end