From d48b95ffafc97a45da7e1104c9f87552bb03f767 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 24 Aug 2018 14:06:04 -0700 Subject: [PATCH] Check :verify_host_key value for :never or if falsey --- plugins/synced_folders/rsync/helper.rb | 2 +- .../synced_folders/rsync/helper_test.rb | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/plugins/synced_folders/rsync/helper.rb b/plugins/synced_folders/rsync/helper.rb index b915873bd..892649e2f 100644 --- a/plugins/synced_folders/rsync/helper.rb +++ b/plugins/synced_folders/rsync/helper.rb @@ -101,7 +101,7 @@ module VagrantPlugins end # no strict hostkey checking unless paranoid - if ! ssh_info[:verify_host_key] + if ssh_info[:verify_host_key] == :never || !ssh_info[:verify_host_key] rsh += [ "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null"] diff --git a/test/unit/plugins/synced_folders/rsync/helper_test.rb b/test/unit/plugins/synced_folders/rsync/helper_test.rb index ddb9279e7..de8f41503 100644 --- a/test/unit/plugins/synced_folders/rsync/helper_test.rb +++ b/test/unit/plugins/synced_folders/rsync/helper_test.rb @@ -263,6 +263,26 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do subject.rsync_single(machine, ssh_info, opts) end + it "includes StrictHostKeyChecking, and UserKnownHostsFile when verify_host_key is false" do + expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args| + expect(args[9]).to include('StrictHostKeyChecking') + expect(args[9]).to include('UserKnownHostsFile') + }.and_return(result) + + subject.rsync_single(machine, ssh_info, opts) + end + + it "includes StrictHostKeyChecking, and UserKnownHostsFile when verify_host_key is :never" do + ssh_info[:verify_host_key] = :never + + expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args| + expect(args[9]).to include('StrictHostKeyChecking') + expect(args[9]).to include('UserKnownHostsFile') + }.and_return(result) + + subject.rsync_single(machine, ssh_info, opts) + end + it "omits IdentitiesOnly with keys_only = false" do ssh_info[:keys_only] = false