diff --git a/vagrant/lib/forklift/box_distributor.rb b/vagrant/lib/forklift/box_distributor.rb index c8508c814..e2c6efa8f 100644 --- a/vagrant/lib/forklift/box_distributor.rb +++ b/vagrant/lib/forklift/box_distributor.rb @@ -60,8 +60,17 @@ def distribute! end end - def fetch_from_box_or_settings(box, key) - box.fetch(key) { @settings.fetch(key, nil) } + def fetch_setting(box, key, default = nil) + box.fetch(key) { @settings.fetch(key, default) } + end + + def argv_include_any?(tokens) + tokens.any? { |token| ARGV.include?(token) } + end + + def add_ssh_setting(box, machine, key) + return unless (value = fetch_setting(box, "ssh_#{key}")).nil? + machine.ssh.send("#{key}=", value) end def define_vm(config, box = {}) @@ -71,9 +80,9 @@ def define_vm(config, box = {}) machine.vm.box = box.fetch('box_name', nil) machine.vm.box_version = box.fetch('box_version', nil) - %w[username forward_agent keys_only].each do |key| - unless (value = fetch_from_box_or_settings(box, "ssh_#{key}")).nil? - machine.ssh.send("#{key}=", value) + unless fetch_setting(box, 'use_ssh_settings_vagrant_ssh_only', false) && !argv_include_any?(%w[ssh ssh-config]) + %w[username forward_agent keys_only].each do |key| + add_ssh_setting(box, machine, key) end end