From 6969e32fa58116b738edb288f98e628e23cd14fc Mon Sep 17 00:00:00 2001 From: Jeremy Daer Date: Thu, 3 Oct 2024 09:24:29 -0700 Subject: [PATCH] SSH proxy: allow using a bare hostname without root@ Otherwise we can't connect to the proxy as the local user. We shouldn't have to provide a specific username, and nobody's going to want to use root as the proxy user. This is hard to deprecate without introducing new config. A clean break is probably clearest. --- lib/kamal/configuration/docs/ssh.yml | 2 +- lib/kamal/configuration/ssh.rb | 6 +++--- test/configuration/ssh_test.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/kamal/configuration/docs/ssh.yml b/lib/kamal/configuration/docs/ssh.yml index 88fcd1327..813881e61 100644 --- a/lib/kamal/configuration/docs/ssh.yml +++ b/lib/kamal/configuration/docs/ssh.yml @@ -32,7 +32,7 @@ ssh: # Proxy host # # Specified in the form or @ - proxy: root@proxy-host + proxy: proxy-host # Proxy command # diff --git a/lib/kamal/configuration/ssh.rb b/lib/kamal/configuration/ssh.rb index dc88367e2..993c746e6 100644 --- a/lib/kamal/configuration/ssh.rb +++ b/lib/kamal/configuration/ssh.rb @@ -19,9 +19,9 @@ def port end def proxy - if (proxy = ssh_config["proxy"]) - Net::SSH::Proxy::Jump.new(proxy.include?("@") ? proxy : "root@#{proxy}") - elsif (proxy_command = ssh_config["proxy_command"]) + if proxy = ssh_config["proxy"] + Net::SSH::Proxy::Jump.new(proxy) + elsif proxy_command = ssh_config["proxy_command"] Net::SSH::Proxy::Command.new(proxy_command) end end diff --git a/test/configuration/ssh_test.rb b/test/configuration/ssh_test.rb index 76d1ae9a7..987335197 100644 --- a/test/configuration/ssh_test.rb +++ b/test/configuration/ssh_test.rb @@ -30,7 +30,7 @@ class ConfigurationSshTest < ActiveSupport::TestCase test "ssh options with proxy host" do config = Kamal::Configuration.new(@deploy.tap { |c| c.merge!(ssh: { "proxy" => "1.2.3.4" }) }) - assert_equal "root@1.2.3.4", config.ssh.options[:proxy].jump_proxies + assert_equal "1.2.3.4", config.ssh.options[:proxy].jump_proxies end test "ssh options with proxy host and user" do