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
- CLI Flag: Add
--ssh-port <PORT> to remote commands (gateway add, gateway start, etc).
- Internal API: Add
ssh_port: Option<u16> to RemoteOptions.
- 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
Problem Statement
openshell gateway add ssh://user@host:8080parses8080as 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 touser@host, which forces the underlying Docker library to default to port 22.Proposed Design
--ssh-port <PORT>to remote commands (gateway add,gateway start, etc).ssh_port: Option<u16>toRemoteOptions.create_ssh_docker_client, append the port to the bollard connection string if set (ssh://user@host:PORT).Alternatives Considered
~/.ssh/configalias: Users define aHostwith a customPort. Rejected: This is currently broken.resolve_ssh_hostnameinmetadata.rsonly parses thehostnameline fromssh -Gand ignores theportline, so the custom port is lost before the connection starts.ssh://user@host:2222:8080. Rejected: Invalid URL format.Agent Investigation
crates/openshell-cli/src/run.rsL925: URL parser assigns the parsed port to the gateway.crates/openshell-bootstrap/src/lib.rsL59:RemoteOptionsstruct has nossh_portfield.crates/openshell-bootstrap/src/docker.rsL240:create_ssh_docker_clientpassesssh://user@hosttobollardwithout a port.crates/openshell-bootstrap/src/metadata.rsL164:resolve_ssh_hostnameignores theportfield fromssh -Goutput.Checklist