diff --git a/lib/net/ssh/config.rb b/lib/net/ssh/config.rb index 86c75f53c..a2397102b 100644 --- a/lib/net/ssh/config.rb +++ b/lib/net/ssh/config.rb @@ -155,6 +155,9 @@ def load(path, host, settings = {}, base_dir = nil) %w[proxyjump proxycommand].each do |proxy_key| if (proxy_value = settings.delete(proxy_key)) settings['proxy'] ||= [proxy_key, proxy_value] + if proxy_key == 'proxyjump' and proxy_value == 'none' + settings.delete('proxy') + end end end end diff --git a/lib/net/ssh/proxy/jump.rb b/lib/net/ssh/proxy/jump.rb index a5de7d93e..6c603ff01 100644 --- a/lib/net/ssh/proxy/jump.rb +++ b/lib/net/ssh/proxy/jump.rb @@ -43,9 +43,11 @@ def build_proxy_command_equivalent(connection_options = nil) template << " -p #{uri.port}" if uri.port template << " -J #{extra_jumps}" if extra_jumps template << " -F #{config}" if config != true && config - template << " -W %h:%p " - template << uri.host - + # When ProxyJump is set to none explicity disable the jumphost + unless uri.host == 'none' + template << " -W %h:%p " + template << uri.host + end @command_line_template = template end end diff --git a/test/test_proxy_jump.rb b/test/test_proxy_jump.rb index 38363033e..c00ed30da 100644 --- a/test/test_proxy_jump.rb +++ b/test/test_proxy_jump.rb @@ -7,6 +7,12 @@ def test_is_a_proxy_command assert proxy.is_a?(Net::SSH::Proxy::Command) end + def test_proxy_none + proxy = Net::SSH::Proxy::Jump.new("none") + proxy.build_proxy_command_equivalent + assert_equal "ssh", proxy.command_line_template + end + def test_host proxy = Net::SSH::Proxy::Jump.new("jumphost") proxy.build_proxy_command_equivalent