diff --git a/pkg/reversesshfs/reversesshfs.go b/pkg/reversesshfs/reversesshfs.go index 323528d..93bf295 100644 --- a/pkg/reversesshfs/reversesshfs.go +++ b/pkg/reversesshfs/reversesshfs.go @@ -9,6 +9,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strconv" "strings" @@ -79,6 +80,17 @@ func DetectOpensshSftpServerBinary() string { return exe } } + if runtime.GOOS == "windows" { + // unix path is like "/usr/lib/ssh/sftp-server" + cygpathCmd := exec.Command("cygpath", "-w", "/usr/lib/ssh/sftp-server") + // windows path is like `C:\msys64\usr\lib\ssh\sftp-server.exe` + if out, err := cygpathCmd.Output(); err == nil { + sftpServer := strings.TrimSpace(string(out)) + if exe, err := exec.LookPath(sftpServer); err == nil { + return exe + } + } + } candidates := []string{ "/usr/libexec/sftp-server", // macOS, OpenWrt "/usr/libexec/openssh/sftp-server", // Fedora