kamal icon indicating copy to clipboard operation
kamal copied to clipboard

Support per-host SSH port configuration for servers and accessories

Open activeliang opened this issue 6 months ago • 1 comments

Hi team,

I'm trying to deploy to two different servers:

  • web goes to VPS1, using default SSH port 22
  • accessories.db goes to VPS2, using custom SSH port 10234

My current deploy.yml looks like this:

servers:
  web:
    hosts:
      - xx.xx.xx.xx

accessories:
  db:
    image: library/postgres:17.4
    host: xx.xx.xx.xx

But I don't see a way to specify different SSH ports for each host. Setting a global ssh.port affects all hosts, which doesn't work in this case.

Question: Does Kamal currently support this kind of setup (different SSH ports per host)? If not, could it be supported in the future?

Thanks!

activeliang avatar Jul 12 '25 04:07 activeliang

It uses SSHKit under the hood, which supports per host SSH port and the code is already there, e.g: https://github.com/basecamp/kamal/blob/4b88852aea58bf94009a6d854afdc630a5c111b5/lib/kamal/cli/base.rb#L155-L159

I was checking the Accessory code and looks like it requires some refactor to allow connections via SSH using a non-default port, e.g: https://github.com/basecamp/kamal/blob/4b88852aea58bf94009a6d854afdc630a5c111b5/lib/kamal/cli/accessory.rb#L64-L67

ruyrocha avatar Jul 23 '25 02:07 ruyrocha