diff --git a/pkg/reversesshfs/reversesshfs.go b/pkg/reversesshfs/reversesshfs.go index edec7ea..aa70cea 100644 --- a/pkg/reversesshfs/reversesshfs.go +++ b/pkg/reversesshfs/reversesshfs.go @@ -133,7 +133,11 @@ func (rsf *ReverseSSHFS) Start() error { } if runtime.GOOS == "windows" && path.IsAbs(rsf.LocalPath) { logrus.Infof("Accepting %q Unix path, assuming Cygwin/msys2 OpenSSH", rsf.LocalPath) + // Convert MSYS2 path to Windows native path + rsf.LocalPath = convertMSYS2Path(rsf.LocalPath) + logrus.Infof("Converted path for native Windows OpenSSH: %q", rsf.LocalPath) } + if !path.IsAbs(rsf.RemotePath) { return fmt.Errorf("unexpected relative path: %q", rsf.RemotePath) } @@ -327,3 +331,14 @@ func (rsf *ReverseSSHFS) Close() error { } return nil } + +// convertMSYS2Path converts an MSYS2 style path (e.g., /c/Users/...) to a Windows native path +func convertMSYS2Path(localPath string) string { + if len(localPath) >= 3 && localPath[0] == '/' && localPath[2] == '/' { + driveLetter := strings.ToUpper(string(localPath[1])) + // Explicitly force backslashes, bypassing WSL/Linux environment quirks + remainingPath := strings.ReplaceAll(localPath[2:], "/", "\\") + return driveLetter + ":" + remainingPath + } + return localPath +} diff --git a/pkg/reversesshfs/reversesshfs_test.go b/pkg/reversesshfs/reversesshfs_test.go index 28be959..eb6c323 100644 --- a/pkg/reversesshfs/reversesshfs_test.go +++ b/pkg/reversesshfs/reversesshfs_test.go @@ -33,3 +33,16 @@ func TestAddQuotes(t *testing.T) { } } } + +func TestConvertMSYS2Path(t *testing.T) { + inputPath := "/c/Users/lts" + expectedPath := "C:\\Users\\lts" + + actualPath := convertMSYS2Path(inputPath) + + if actualPath != expectedPath { + t.Errorf("Conversion failed: expected %q, got %q", expectedPath, actualPath) + } else { + t.Logf("Success! Converted path for native Windows OpenSSH: %q", actualPath) + } +}