From 00f6aca5ee8efa6660e0b49fe9ed6efc405b9d80 Mon Sep 17 00:00:00 2001 From: Trevor Vaughan Date: Tue, 2 Jun 2020 11:51:06 -0400 Subject: [PATCH 1/2] [BRK-1655] Better strict_host_key_checking fix * Take into account that :paranoid is deprecated * Take into account that true/false is deprecated for :verify_host_key --- lib/beaker/ssh_connection.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/beaker/ssh_connection.rb b/lib/beaker/ssh_connection.rb index 2ac958f1c8..293ef12cd3 100644 --- a/lib/beaker/ssh_connection.rb +++ b/lib/beaker/ssh_connection.rb @@ -69,8 +69,15 @@ def connect_block host, user, ssh_opts, options begin @logger.debug "Attempting ssh connection to #{host}, user: #{user}, opts: #{ssh_opts}" + # Work around net-ssh 6+ incompatibilities if ssh_opts.include?(:strict_host_key_checking) && (Net::SSH::Version::CURRENT.major > 5) - ssh_opts[:paranoid] = ssh_opts.delete(:strict_host_key_checking) + strict_host_key_checking = ssh_opts.delete(:strict_host_key_checking) + + if ssh_opts[:verify_host_key].nil? + ssh_opts[:verify_host_key] = strict_host_key_checking ? :always : :never + else + ssh_opts[:verify_host_key] = (ssh_opts[:verify_host_key] ? :always : :never) unless ssh_opts[:verify_host_key].is_a?(Symbol) + end end Net::SSH.start(host, user, ssh_opts) From e77274a6a0836e7bdf56b0515a7f9215849dfe6f Mon Sep 17 00:00:00 2001 From: Trevor Vaughan Date: Tue, 9 Jun 2020 17:38:48 -0400 Subject: [PATCH 2/2] Update lib/beaker/ssh_connection.rb Co-authored-by: Brandon High --- lib/beaker/ssh_connection.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/beaker/ssh_connection.rb b/lib/beaker/ssh_connection.rb index 293ef12cd3..c890ded9da 100644 --- a/lib/beaker/ssh_connection.rb +++ b/lib/beaker/ssh_connection.rb @@ -73,10 +73,8 @@ def connect_block host, user, ssh_opts, options if ssh_opts.include?(:strict_host_key_checking) && (Net::SSH::Version::CURRENT.major > 5) strict_host_key_checking = ssh_opts.delete(:strict_host_key_checking) - if ssh_opts[:verify_host_key].nil? - ssh_opts[:verify_host_key] = strict_host_key_checking ? :always : :never - else - ssh_opts[:verify_host_key] = (ssh_opts[:verify_host_key] ? :always : :never) unless ssh_opts[:verify_host_key].is_a?(Symbol) + unless ssh_opts[:verify_host_key].is_a?(Symbol) + ssh_opts[:verify_host_key] ||= strict_host_key_checking ? :always : :never end end