Repository navigation
Codex Desktop Remote SSH to Windows OpenSSH fails when default shell is PowerShell #22757
Description
What version of the Codex App are you using?
Codex Desktop 26.513.20950 on macOS.
Remote Codex CLI observed:
- Windows native Codex CLI:
codex-cli 0.130.0-alpha.5 - WSL/Linux Codex CLI workaround:
codex-cli 0.130.0
What subscription do you have?
ChatGPT Pro
What platform is your computer?
Local client:
- macOS on arm64
- Codex Desktop app
Remote host:
- Windows laptop over OpenSSH
- Windows OpenSSH default shell set to PowerShell 7 (
pwsh.exe) - Passwordless SSH key auth succeeds
- Remote Windows workspace path:
C:\MethodDev codex app-server --helpworks when run manually in PowerShell
What issue are you seeing?
Codex Desktop Remote SSH discovers the Windows SSH host and authenticates successfully, but the connection fails during app-server bootstrap because the Desktop SSH transport sends POSIX login-shell bootstrap code to a PowerShell remote shell.
The failing remote command in app breadcrumbs includes a POSIX shell probe/exec shape like:
exec "$SHELL" -i -c '... if ( -r /etc/csh.login ) source ... exec /bin/sh -c "$CODEX_REMOTE_PAYLOAD" ...'
Because the remote OpenSSH login shell is PowerShell 7, PowerShell parses that POSIX/csh/sh syntax and fails with:
ParserError:
Line |
1 | . ec "$SHELL" -i -c '\''set loginsh=1; if ( -r /etc/csh.login ) source ...
| ~
| Missing statement block after if ( condition ).
The Codex Desktop UI then reports the SSH connection as failed/reconnecting.
This appears related to shell compatibility issues such as #18183 and #19302, but this case is specifically native Windows OpenSSH with PowerShell as the configured default shell. In this setup, normal SSH and manual codex app-server invocation both work; the failure is the Desktop Remote SSH bootstrap assuming a POSIX-compatible login shell.
What steps can reproduce the bug?
- On a Windows machine, install OpenSSH Server and Codex CLI/Desktop.
- Configure Windows OpenSSH to use PowerShell 7 as the default shell, for example:
New-ItemProperty `
-Path "HKLM:\SOFTWARE\OpenSSH" `
-Name DefaultShell `
-Value "C:\Program Files\PowerShell\7\pwsh.exe" `
-PropertyType String `
-Force
Restart-Service sshd- From a Mac, verify SSH works and lands in PowerShell 7:
ssh windows-host '$PSVersionTable.PSVersion.ToString(); (Get-Location).Path; codex app-server --help'- In Codex Desktop on macOS, add/select the SSH host under Settings -> Connections -> SSH.
- Enable the connection.
- Observe that the connection fails/retries.
- Inspect Codex Desktop breadcrumbs/logs; they show a PowerShell
ParserErrorfrom the POSIX login-shell bootstrap.
What is the expected behavior?
Codex Desktop Remote SSH should support Windows OpenSSH hosts whose default shell is PowerShell, or at least fail with a clear diagnostic that the current Desktop Remote SSH bootstrap requires a POSIX-compatible shell.
A product-level fix could be one of:
- Detect PowerShell/Windows remote shells and use a PowerShell-native bootstrap path.
- Allow per-connection configuration of a bootstrap shell/command, so users can keep PowerShell as their interactive SSH shell while Codex uses an alternate shell for app-server startup.
- Detect unsupported shells before running POSIX syntax and show a clear actionable error.
Workaround
A WSL-backed SSH target works because it gives Codex a POSIX shell:
- run an SSH server inside WSL on another port, e.g.
2222 - connect Codex Desktop to that WSL SSH alias instead of the Windows OpenSSH alias
- install Linux Codex CLI in WSL so
codex app-serveris on PATH - use
/mnt/c/<workspace>for Windows project files - invoke Windows/IIS/PowerShell tools explicitly from WSL with
pwsh.exe,powershell.exe, orcmd.exe
That workaround is usable, but it means native Windows OpenSSH + PowerShell is not a first-class Codex Desktop Remote SSH target today.
Activity
omid-method commentedon May 15, 2026
Adding a concrete repro from my Windows laptop / WSL-backed Codex Desktop setup, based on a live debugging session.
Environment/context:
/mnt/c/MethodDev.bash) on the Windows laptop, not native Windows PowerShell.C:\MethodDevare readable/writable through/mnt/c/MethodDev.C:\Program Files\PowerShell\7\pwsh.exeC:\Windows\System32\WindowsPowerShell\v1.0\powershell.exeC:\Program Files\dotnet\dotnet.exeC:\Users\Omid Rajabi\.dotnet\tools\mtd.exeWhat fails:
From the Codex WSL shell, launching Windows executables through WSL interop fails before the target process can produce normal output.
Minimal repro:
Observed output:
When retried through Codex's escalated command path, the process appeared to start but then exited with:
This is not specific to
pwsh.exe. Similar attempts to launch Windows executables from the WSL-backed Codex session hit the same class of failure:Concrete workflow impact:
I asked Codex to run the local Method workspace health check. The normal command is:
cd C:\MethodDev mtd healthcheck run -aInside the Codex WSL shell:
mtdwas not on the Linux PATH.dotnetwas not installed.mtd.exeglobal tool was found atC:\Users\Omid Rajabi\.dotnet\tools\mtd.exe.mtd.exe,pwsh.exe,powershell.exe,cmd.exe, ordotnet.exefrom Codex failed because WSL interop itself failed.Expected behavior:
A WSL-backed Codex Desktop session on Windows should be able to invoke host Windows executables through normal WSL interop, especially for workflows where the repo lives under
/mnt/cand local development depends on Windows-only tools such as IIS, PowerShell, Windows .NET, and locally installed CLIs.Actual behavior:
Codex can read and edit the workspace under
/mnt/c, but cannot cross the WSL-to-Windows process boundary. That blocks local Windows/IIS/PowerShell workflows from inside Codex even though the underlying tools are installed and should be callable from an ordinary WSL terminal.One additional note: trying to use the
codex-workSSH alias from this WSL environment also failed with DNS/alias resolution:So, in this setup, there was no working fallback from the Codex WSL session to native Windows execution.
bookHsu-shinher commentedon May 20, 2026
Adding another anonymized repro from a Windows Codex Desktop host.
Environment:
26.513.4821.0OpenSSH_for_Windows_9.5p2, LibreSSL 3.8.2127.0.0.1:<non-default-port>)codex-cli 0.130.0sshdwas restricted to loopback only for the reproWhat works outside Codex Desktop:
The second command returns:
What fails in Codex Desktop:
Settings -> Connections -> SSH connections from this PC -> add/enable the Windows OpenSSH alias.
After fixing key auth, the UI shows that SSH authentication succeeds:
Then the connection still fails because the bootstrap appears to send POSIX/csh/sh login-shell probing code to a Windows shell. The UI error includes escaped/ANSI-contaminated output with fragments like:
I tried both native Windows OpenSSH defaults and setting the OpenSSH default shell to PowerShell 7. The result is the same class of failure: SSH auth succeeds, but the remote bootstrap assumes POSIX shell semantics and PowerShell cannot parse the command.
Additional notes:
codex --versionworks over the same SSH alias.This matches the original issue report: native Windows OpenSSH with PowerShell/cmd as the remote shell is not currently handled by the Codex Desktop Remote SSH bootstrap.
mmiladinov commentedon Jul 7, 2026
I am also seeing the same issue.
dustovo commentedon Jul 16, 2026
How to fix this issue?
Codex Desktop version: 26.707.12708.0
Remote OS: Windows
Remote SSH server: Windows OpenSSH
Remote default shell: PowerShell 7.6.3
Failure stage: remote_codex_lookup
Error type: AppServerSshSetupError
SSH authentication succeeds and this works:
ssh remote-server 'codex --version'
codex-cli 0.144.5
However, Codex Desktop sends a POSIX bootstrap payload beginning with:
sh -c 'if [ -z "$SHELL" ] ...
PowerShell then fails with:
ParserError: Missing statement block after if ( condition ).
The remote PATH, SSH key, Codex CLI, Node.js, and PowerShell configuration have all been verified working.
eddy961206 commentedon Aug 2, 2026
same issue here
TomaxMe commentedon Aug 20, 2026
same issue here
padeoe commentedon Aug 20, 2026
same issue
ShiTan-677 commentedon Aug 21, 2026
Adding an independent, anonymized reproduction from a macOS client to a native Windows OpenSSH host. This matches the same root cause with the Windows default
cmd.exeshell (rather than PowerShell).Environment
26.803.61601(build6396)OpenSSH_10.2p110.0.26200.9168OpenSSH_for_Windows_9.5codex-cli 0.147.0cmd.exe~/.ssh/configand was auto-discovered by Desktop; it was not manually entered in the app.Checks that succeed outside Desktop
Using the same SSH alias and identity:
The non-interactive app-server probe also succeeds:
It prints the normal
codex app-serverhelp and exits successfully. The CLI lives in a normal NTFS directory (not the standalone installer's junction), so this is not a PATH or reparse-point failure.Desktop failure
Desktop discovers the alias:
SSH authentication succeeds, and the client can see the Windows SSH implementation:
Immediately afterward, during the Codex path probe, Desktop sends a POSIX bootstrap to the native Windows shell:
The Windows shell rejects it (the original localized output is mojibake in the app log; translated):
The final failure is:
So Desktop never reaches the already-working
codex.exeor starts the app server.Expected behavior
For a native Windows OpenSSH host, Desktop should select a Windows-native bootstrap (PowerShell or cmd-aware), locate
codex.exeusing the remote login shell's WindowsPATH, and start the remote app server without requiring a machine-wide Git Bash default-shell override.The current official SSH workflow says that Desktop starts the remote Codex app server through SSH using the remote user's login shell and requires
codexon that shell'sPATH: https://learn.chatgpt.com/docs/remote-connections#connect-to-an-ssh-hostThis reproduction satisfies those prerequisites; the blocker is specifically the unconditional POSIX bootstrap at
remote_codex_lookup.Pyromaniac6669 commentedon Aug 23, 2026
I am experiencing the same issue. SSH authentication and terminal access work, but the Codex Desktop SSH connection fails during bootstrap with a PowerShell parser error. I hope this can be fixed soon. Thank you!
ken-jo commentedon Sep 11, 2026
Additional reproduction on Desktop 26.903.71938, with a proposed implementation and regression-test plan.
Verified environment and failure boundary
codex-cli 0.147.0.codex --versionover the same SSH connection succeeds.remote_codex_lookup(the step that locates the remote Codex CLI), before successfully completing its CLI lookup/bootstrap.Minimal reproduction (the alias below is a placeholder):
These return
codex-cli 0.147.0and7.6.5. Enabling that SSH host in Desktop produces the failure described in this issue.Selected diagnostic fields, with identifiers and surrounding logs omitted:
The failed initialization command includes the Unix-shell branch
set loginsh=1; if ( -r /etc/csh.login ) source .... The reported PowerShell parser error occurs while Desktop submits a command containing that Unix-shell syntax. This does not mean the target uses csh; the incompatible syntax is embedded in Desktop's login-shell wrapper.This narrows the observed failure to Desktop's remote initialization command selection. It does not establish whether later Windows app-server transport stages would work after this failure is fixed.
Proposed implementation (not an implemented or validated patch)
-NoLogo -NoProfile -NonInteractive. An explicitly generated UTF-16LE-EncodedCommandpayload can reduce quoting problems, but executable discovery and the outer SSH command still require correct escaping and tests. Resolve the CLI in the effective remote environment, return a small structured result, and invoke the supported executable or launcher without assumingsh,nohup,pkill,$SHELL, or Unix paths. Preserve exit codes and impose timeouts.Suggested acceptance tests
Happy to contribute additional sanitized reproduction details and test results in this issue, in line with the repository's contribution policy.