From ce46a67d6df342f0a03606a0ec2c5e91c6827506 Mon Sep 17 00:00:00 2001 From: Pasha Sviderski Date: Wed, 28 Jan 2026 17:44:54 +1000 Subject: [PATCH] fix: ssh args for machine init/add when using ssh+cli --- internal/sshexec/sshcli.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/sshexec/sshcli.go b/internal/sshexec/sshcli.go index 4428a8b5..34ef4c3d 100644 --- a/internal/sshexec/sshcli.go +++ b/internal/sshexec/sshcli.go @@ -30,7 +30,7 @@ func NewSSHCLIRemote(user, host string, port int, keyPath string) *SSHCLIRemote func (r *SSHCLIRemote) buildSSHArgs() []string { args := []string{"-o", "ConnectTimeout=5"} - if r.port != 0 && r.port != 22 { + if r.port != 0 { args = append(args, "-p", strconv.Itoa(r.port)) } @@ -38,7 +38,12 @@ func (r *SSHCLIRemote) buildSSHArgs() []string { args = append(args, "-i", r.keyPath) } - args = append(args, r.user+"@"+r.host) + dst := r.host + if r.user != "" { + dst = fmt.Sprintf("%s@%s", r.user, dst) + } + args = append(args, dst) + return args }