@@ -52,7 +52,7 @@ func (rsf *ReverseSSHFS) Prepare() error {
5252 sshArgs = append (sshArgs , "-p" , strconv .Itoa (rsf .Port ))
5353 }
5454 sshArgs = append (sshArgs , rsf .Host , "--" )
55- sshArgs = append (sshArgs , "mkdir" , "-p" , strconv . Quote (rsf .RemotePath ))
55+ sshArgs = append (sshArgs , "mkdir" , "-p" , addQuotes (rsf .RemotePath ))
5656 sshCmd := exec .Command (sshBinary , sshArgs ... )
5757 logrus .Debugf ("executing ssh for preparing sshfs: %s %v" , sshCmd .Path , sshCmd .Args )
5858 out , err := sshCmd .CombinedOutput ()
@@ -141,7 +141,7 @@ func (rsf *ReverseSSHFS) Start() error {
141141 sshArgs = append (sshArgs , "-p" , strconv .Itoa (rsf .Port ))
142142 }
143143 sshArgs = append (sshArgs , rsf .Host , "--" )
144- sshArgs = append (sshArgs , "sshfs" , strconv . Quote (":" + rsf .LocalPath ), strconv . Quote (rsf .RemotePath ), "-o" , "slave" )
144+ sshArgs = append (sshArgs , "sshfs" , addQuotes (":" + rsf .LocalPath ), addQuotes (rsf .RemotePath ), "-o" , "slave" )
145145 if rsf .Readonly {
146146 sshArgs = append (sshArgs , "-o" , "ro" )
147147 }
@@ -252,6 +252,18 @@ func (rsf *ReverseSSHFS) Start() error {
252252 return nil
253253}
254254
255+ func addQuotes (input string ) string {
256+ input = strconv .Quote (input )
257+ // exec.Command on Windows would escape wrapping double quotes in a way, which is not compatible
258+ // with passing arguments into bash shell over ssh, replacing with single quotes as a workaround.
259+ if runtime .GOOS == "windows" {
260+ input = strings .TrimPrefix (input , "\" " )
261+ input = strings .TrimSuffix (input , "\" " )
262+ return fmt .Sprintf (`'%s'` , input )
263+ }
264+ return input
265+ }
266+
255267func (rsf * ReverseSSHFS ) waitForRemoteReady () error {
256268 scriptName := "wait-for-remote-ready"
257269 scriptTemplate := `#!/bin/sh
0 commit comments