Skip to content

Commit 5a57e51

Browse files
committed
fix: Windows ssh command quoting
Signed-off-by: Justin Alvarez <[email protected]>
1 parent de100c6 commit 5a57e51

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pkg/sshutil/sshutil.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,10 @@ func CommonOpts(useDotSSH bool) ([]string, error) {
138138
var opts []string
139139
if runtime.GOOS == "windows" {
140140
privateKeyPath = ioutilx.CanonicalWindowsPath(privateKeyPath)
141+
opts = []string{fmt.Sprintf(`IdentityFile='%s'`, privateKeyPath)}
142+
} else {
143+
opts = []string{fmt.Sprintf(`IdentityFile="%s"`, privateKeyPath)}
141144
}
142-
opts = []string{fmt.Sprintf(`IdentityFile="%s"`, privateKeyPath)}
143145

144146
// Append all private keys corresponding to ~/.ssh/*.pub to keep old instances working
145147
// that had been created before lima started using an internal identity.
@@ -170,7 +172,7 @@ func CommonOpts(useDotSSH bool) ([]string, error) {
170172
// Fail on permission-related and other path errors
171173
return nil, err
172174
}
173-
opts = append(opts, "IdentityFile=\""+privateKeyPath+"\"")
175+
opts = append(opts, "IdentityFile='"+privateKeyPath+"'")
174176
}
175177
}
176178

@@ -229,10 +231,11 @@ func SSHOpts(instDir string, useDotSSH, forwardAgent bool, forwardX11 bool, forw
229231
if err != nil {
230232
return nil, err
231233
}
234+
controlPath := fmt.Sprintf(`ControlPath="%s"`, controlSock)
232235
if runtime.GOOS == "windows" {
233236
controlSock = ioutilx.CanonicalWindowsPath(controlSock)
237+
controlPath = fmt.Sprintf(`ControlPath='%s'`, controlSock)
234238
}
235-
controlPath := fmt.Sprintf(`ControlPath="%s"`, controlSock)
236239
opts = append(opts,
237240
fmt.Sprintf("User=%s", u.Username), // guest and host have the same username, but we should specify the username explicitly (#85)
238241
"ControlMaster=auto",

0 commit comments

Comments
 (0)