From 0e4f1758171f6e66c774460632292be8633d6d13 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 and we can't use ~/.ssh/config to set User directives. Defaulting to root@ is hard to deprecate without introducing new config. A clean break is probably clearest. --- lib/kamal/configuration/docs/ssh.yml | 4 ++-- lib/kamal/configuration/ssh.rb | 6 +++--- test/configuration/ssh_test.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/kamal/configuration/docs/ssh.yml b/lib/kamal/configuration/docs/ssh.yml index 8d1033521..291c9c9f1 100644 --- a/lib/kamal/configuration/docs/ssh.yml +++ b/lib/kamal/configuration/docs/ssh.yml @@ -29,8 +29,8 @@ ssh: # Proxy host # - # Specified in the form or @: - proxy: root@proxy-host + # Specified in the form or @ + 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