diff --git a/pkg/remote/remote.go b/pkg/remote/remote.go index bbf054c..712cc59 100644 --- a/pkg/remote/remote.go +++ b/pkg/remote/remote.go @@ -56,7 +56,16 @@ func Dial(ctx context.Context, cfg Config) (*Server, error) { remoteCmd += " --yolo" } - cmd := exec.CommandContext(ctx, "ssh", cfg.SSHTarget, remoteCmd) + // Parse optional port from SSHTarget (user@host:port or host:port) + sshArgs := []string{} + sshTarget := cfg.SSHTarget + if host, port, ok := strings.Cut(sshTarget, ":"); ok && port != "" { + sshTarget = host + sshArgs = append(sshArgs, "-p", port) + } + sshArgs = append(sshArgs, sshTarget, remoteCmd) + + cmd := exec.CommandContext(ctx, "ssh", sshArgs...) cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} stdin, err := cmd.StdinPipe()