Skip to content

feat(cli): support custom SSH port for remote gateway deployment #619

@bokerh

Description

@bokerh

Problem Statement

openshell gateway add ssh://user@host:8080 parses 8080 as the gateway's HTTPS port. There is no way to specify a custom SSH port (e.g. 2222) for the connection itself. The CLI strips the SSH connection down to user@host, which forces the underlying Docker library to default to port 22.

Proposed Design

  1. CLI Flag: Add --ssh-port <PORT> to remote commands (gateway add, gateway start, etc).
  2. Internal API: Add ssh_port: Option<u16> to RemoteOptions.
  3. Execution: In create_ssh_docker_client, append the port to the bollard connection string if set (ssh://user@host:PORT).

Alternatives Considered

  • ~/.ssh/config alias: Users define a Host with a custom Port. Rejected: This is currently broken. resolve_ssh_hostname in metadata.rs only parses the hostname line from ssh -G and ignores the port line, so the custom port is lost before the connection starts.
  • URI overloading: Support ssh://user@host:2222:8080. Rejected: Invalid URL format.

Agent Investigation

  • crates/openshell-cli/src/run.rs L925: URL parser assigns the parsed port to the gateway.
  • crates/openshell-bootstrap/src/lib.rs L59: RemoteOptions struct has no ssh_port field.
  • crates/openshell-bootstrap/src/docker.rs L240: create_ssh_docker_client passes ssh://user@host to bollard without a port.
  • crates/openshell-bootstrap/src/metadata.rs L164: resolve_ssh_hostname ignores the port field from ssh -G output.

Checklist

  • I've reviewed existing issues and the architecture docs
  • This is a design proposal, not a "please build this" request

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions