Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add none support to ProxyJump #893

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/net/ssh/config.rb
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions lib/net/ssh/proxy/jump.rb
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test/test_proxy_jump.rb
Expand Up @@ -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
Expand Down