Skip to content
This repository has been archived by the owner on Mar 19, 2022. It is now read-only.

Net::SSH - Deprecation warning for option :paranoid #529

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/knife-solo/ssh_command.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
module KnifeSolo
module SshCommand

def self.load_deps
require 'knife-solo/ssh_connection'
require 'knife-solo/tools'
require 'net/ssh'
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
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions test/ssh_command_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down