Skip to content

Bug: SSH connection fails when targeting Windows host due to hardcoded 'sh' wrapper (corrupted CP949 error 'sh'() Ǵ...) #3427

Description

@Laser-Cho

Description

When attempting to connect or reinstall a connection (wsh conn reinstall) to a remote target that runs on Windows OS (with native OpenSSH server enabled), the process fails during client platform detection. The terminal prints a corrupted, unreadable error message:

Error: reinstalling connection: error detecting client platform: error running uname -sm: Process exited with status 1, stderr: 'sh'()  Ǵ  ,     α, Ǵ ġ  ƴմϴ.

Root Cause Analysis

  1. Decoding Error (CP949 to UTF-8)
    The unreadable message 'sh'() Ǵ , α, Ǵ ġ ƴմϴ. is the CP949-encoded Windows Command Prompt/PowerShell error message decoded as UTF-8 in Go. The original Korean error message is:
    'sh'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는 배치 파일이 아닙니다.
    (English translation: 'sh' is not recognized as an internal or external command, operable program or batch file.)

  2. Hardcoded sh -c wrapper
    In the Go source code, when detecting the platform of the remote machine:

  • In pkg/remote/connutil.go inside GetClientPlatform, uname -sm is run to determine the target OS and architecture.

  • However, in pkg/genconn/genconn.go inside BuildShellCommand, all remote shell commands are wrapped in sh -c by default:

    return fmt.Sprintf("sh -c %s", shellutil.HardQuote(envVars.String()+shellCmd)), nil
  • Since a Windows host does not have sh installed in its %PATH% by default, executing sh -c 'uname -sm' fails immediately with the Windows command-not-found error.

Environment

  • Client OS: Windows/Linux/macOS
  • Remote Target OS: Windows (running OpenSSH)
  • Wave Terminal / wsh version: v0.14.5

Suggested Mitigation / Fixes

  • Detection fallback: If sh fails or is missing, try executing commands via cmd.exe /c or powershell -Command when targeting Windows hosts, or allow specifying the shell/OS configuration beforehand.
  • Graceful parsing: Handle different shell error codes and decoding errors (like CP949 fallback for Windows targets) to show friendly messages when the shell invocation fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions