Skip to content

Commit

Permalink
Add SSH port option
Browse files Browse the repository at this point in the history
  • Loading branch information
leonvogt committed Oct 1, 2023
1 parent 83a2d52 commit b3f85dc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/kamal/configuration/ssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ def user
config.fetch("user", "root")
end

def port
config.fetch("port", 22)
end

def proxy
if (proxy = config["proxy"])
Net::SSH::Proxy::Jump.new(proxy.include?("@") ? proxy : "root@#{proxy}")
Expand All @@ -18,7 +22,7 @@ def proxy
end

def options
{ user: user, proxy: proxy, logger: logger, keepalive: true, keepalive_interval: 30 }.compact
{ user: user, port: port, proxy: proxy, logger: logger, keepalive: true, keepalive_interval: 30 }.compact
end

def to_h
Expand Down
3 changes: 3 additions & 0 deletions test/configuration/ssh_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class ConfigurationSshTest < ActiveSupport::TestCase

config = Kamal::Configuration.new(@deploy.tap { |c| c.merge!(ssh: { "log_level" => "debug" }) })
assert_equal 0, config.ssh.options[:logger].level

config = Kamal::Configuration.new(@deploy.tap { |c| c.merge!(ssh: { "port" => 2222 }) })
assert_equal 2222, config.ssh.options[:port]
end

test "ssh options with proxy host" do
Expand Down
2 changes: 1 addition & 1 deletion test/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class ConfigurationTest < ActiveSupport::TestCase
:repository=>"dhh/app",
:absolute_image=>"dhh/app:missing",
:service_with_version=>"app-missing",
:ssh_options=>{ :user=>"root", log_level: :fatal, keepalive: true, keepalive_interval: 30 },
:ssh_options=>{ :user=>"root", port: 22, log_level: :fatal, keepalive: true, keepalive_interval: 30 },
:sshkit=>{},
:volume_args=>["--volume", "/local/path:/container/path"],
:builder=>{},
Expand Down

0 comments on commit b3f85dc

Please sign in to comment.