lib/kitchen/transport/ssh.rb in test-kitchen-1.25.0 vs lib/kitchen/transport/ssh.rb in test-kitchen-2.0.0
- old
+ new
@@ -230,11 +230,11 @@
RESCUE_EXCEPTIONS_ON_ESTABLISH = [
Errno::EACCES, Errno::EALREADY, Errno::EADDRINUSE, Errno::ECONNREFUSED, Errno::ETIMEDOUT,
Errno::ECONNRESET, Errno::ENETUNREACH, Errno::EHOSTUNREACH, Errno::EPIPE,
Net::SSH::Disconnect, Net::SSH::AuthenticationFailed, Net::SSH::ConnectionTimeout,
- Net::SSH::Proxy::ConnectError, Timeout::Error
+ Timeout::Error
].freeze
# @return [Integer] cap on number of parallel ssh sessions we can use
# @api private
attr_reader :max_ssh_sessions
@@ -496,13 +496,13 @@
opts[:password] = data[:password] if data.key?(:password)
opts[:forward_agent] = data[:forward_agent] if data.key?(:forward_agent)
opts[:verbose] = data[:verbose].to_sym if data.key?(:verbose)
- # disable host key verification. The hash key to use
- # depends on the version of net-ssh in use.
- opts[verify_host_key_option] = false
+ # disable host key verification. The hash key and value to use
+ # depend on the version of net-ssh in use
+ opts[verify_host_key_option] = verify_host_key_value
opts
end
#
@@ -520,9 +520,21 @@
def verify_host_key_option
current_net_ssh = Net::SSH::Version::CURRENT
new_option_version = Net::SSH::Version[4, 2, 0]
current_net_ssh >= new_option_version ? :verify_host_key : :paranoid
+ end
+
+ #
+ # Returns the correct host-key-verification option value to use depending
+ # on what version of net-ssh is in use. In net-ssh <= 5, the supported
+ # parameter is false but in 5.0, it became `:never`
+ #
+ def verify_host_key_value
+ current_net_ssh = Net::SSH::Version::CURRENT
+ new_option_version = Net::SSH::Version[5, 0, 0]
+
+ current_net_ssh >= new_option_version ? :never : false
end
# Creates a new SSH Connection instance and save it for potential future
# reuse.
#