Title: Bug: CLI Incorrect Quote Handling in ProxyCommand on Windows · Issue #18503 · coder/coder · GitHub
Open Graph Title: Bug: CLI Incorrect Quote Handling in ProxyCommand on Windows · Issue #18503 · coder/coder
X Title: Bug: CLI Incorrect Quote Handling in ProxyCommand on Windows · Issue #18503 · coder/coder
Description: Summary The coder config-ssh command generates SSH configuration with incorrect quote handling on Windows, causing SSH connection failures due to malformed syntax. This does not happen on Mac/Linux since the executable is not wrapped Env...
Open Graph Description: Summary The coder config-ssh command generates SSH configuration with incorrect quote handling on Windows, causing SSH connection failures due to malformed syntax. This does not happen on Mac/Linux...
X Description: Summary The coder config-ssh command generates SSH configuration with incorrect quote handling on Windows, causing SSH connection failures due to malformed syntax. This does not happen on Mac/Linux...
Opengraph URL: https://github.com/coder/coder/issues/18503
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug: CLI Incorrect Quote Handling in ProxyCommand on Windows","articleBody":"## Summary\n\nThe `coder config-ssh` command generates SSH configuration with incorrect quote handling on Windows, causing SSH connection failures due to malformed syntax.\n\nThis does not happen on Mac/Linux since the executable is not wrapped\n\n## Environment\n\n- **OS**: Windows\n- **Coder Version**: 1.22, 1.23 (confirmed, likely affects other versions)\n- **Installation Method**: WinGet (via `C:\\Users\\[USER]\\AppData\\Local\\Microsoft\\WinGet\\Links\\coder.exe`)\n\n## Problem Description\n\nWhen running `coder config-ssh`, the generated SSH configuration contains nested double quotes that are invalid in SSH config syntax, causing SSH to fail with parsing errors.\n\n### Generated Configuration (Incorrect)\n```ssh\nHost *.coder\n ConnectTimeout=0\n StrictHostKeyChecking=no\n UserKnownHostsFile=/dev/null\n LogLevel ERROR\n\nMatch host *.coder !exec \"\"C:\\Users\\[USER]\\AppData\\Local\\Microsoft\\WinGet\\Links\\coder.exe\" connect exists %h\"\n ProxyCommand \"C:\\Users\\[USER]\\AppData\\Local\\Microsoft\\WinGet\\Links\\coder.exe\" --global-config \"C:\\Users\\[USER]\\AppData\\Roaming\\coderv2\" ssh --stdio --hostname-suffix coder %h\n# ------------END-CODER------------\n```\n\n### Error Output\n```\nC:\\Users\\[USER]\\.ssh>ssh coder.magenta-chipmunk-80.main\nMissing Match criteria for exec\nC:\\\\Users\\\\[USER]/.ssh/config line 29: Bad Match condition\nC:\\\\Users\\\\[USER]/.ssh/config: terminating, 1 bad configuration options\n```\n\n## Root Cause\n\nThe issue is related to improper quote handling where nested double quotes are not properly escaped or alternated with single quotes\n. In the `Match` directive, the `!exec` command contains double quotes within an already double-quoted parameter, creating invalid syntax.\n\n## Expected Behavior\n\nThe generated SSH configuration should use proper quote alternation to avoid nested quote conflicts.\n\n### Correct Configuration (Should Generate)\n```ssh\nHost *.coder\n ConnectTimeout=0\n StrictHostKeyChecking=no\n UserKnownHostsFile=/dev/null\n LogLevel ERROR\n\nMatch host *.coder !exec \"'C:\\Users\\[USER]\\AppData\\Local\\Microsoft\\WinGet\\Links\\coder.exe' connect exists %h\"\n ProxyCommand \"C:\\Users\\[USER]\\AppData\\Local\\Microsoft\\WinGet\\Links\\coder.exe\" --global-config \"C:\\Users\\[USER]\\AppData\\Roaming\\coderv2\" ssh --stdio --hostname-suffix coder %h\n# ------------END-CODER------------\n```\n\n## Current Workaround\n\nManually edit the `.ssh/config` file and replace the inner double quotes with single quotes:\n\n**Change from:**\n```\nMatch host *.coder !exec \"\"C:\\Users\\[USER]\\AppData\\Local\\Microsoft\\WinGet\\Links\\coder.exe\" connect exists %h\"\n```\n\n**Change to:**\n```\nMatch host *.coder !exec \"'C:\\Users\\[USER]\\AppData\\Local\\Microsoft\\WinGet\\Links\\coder.exe' connect exists %h\"\n```\n\n## Impact\n\nThis bug prevents users from connecting to Coder workspaces via SSH on Windows systems, requiring manual configuration file editing after each `coder config-ssh` run.\n\n## Suggested Fix\n\nThe CLI should implement proper quote handling logic for Windows paths:\n\n1. **Use single quotes for inner quotes** when the outer context uses double quotes\n2. **Detect Windows paths** (containing `:\\` or spaces) and apply appropriate quoting strategy\n3. **Consider using single quotes for the entire command** when no variable expansion is needed\n\n## Related Information\n\n- The `--coder-binary-path` option allows specifying the absolute path to the coder binary used in ProxyCommand\n\n- SSH ProxyCommand parameter configuration is a common source of quoting issues\n\n- Similar quote handling issues have been reported in other SSH tooling\n\n## Additional Context\n\nThis issue specifically affects Windows installations where the coder binary path contains spaces (common with WinGet installations in `AppData\\Local\\Microsoft\\WinGet\\Links\\`). The SSH configuration parser strictly requires proper quote nesting, and the current implementation generates syntactically invalid configurations.\n","author":{"url":"https://github.com/bjornrobertsson","@type":"Person","name":"bjornrobertsson"},"datePublished":"2025-06-23T15:05:15Z","url":"https://github.com/coder/coder/issues/18503"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9cb76b9d-786b-ea7f-fd99-f2c23c16787c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DED2:363D8E:312C87A:3E5FF65:6B01B4E4 |
| html-safe-nonce | d5f6afbc7735c9be20bd183c671d94233d3399ba030a42fed79cb95cf799b8f9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERUQyOjM2M0Q4RTozMTJDODdBOjNFNUZGNjU6NkIwMUI0RTQiLCJ2aXNpdG9yX2lkIjoiNzUzNzc2Mzc4MzQ3NzkzMzI4NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d5dea499f1c0b1e5e90ffc8bceaedbc0c7c333b8157c369a929a9e5ee4ad4bb5 |
| hovercard-subject-tag | issue:3168537621 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/coder/coder/18503/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fec1cfa8f8ea754b6f8368839707fdb6b68944ffcc6d62ef9358894649c05e6e/coder/coder/issues/18503 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fec1cfa8f8ea754b6f8368839707fdb6b68944ffcc6d62ef9358894649c05e6e/coder/coder/issues/18503 |
| og:image:alt | Summary The coder config-ssh command generates SSH configuration with incorrect quote handling on Windows, causing SSH connection failures due to malformed syntax. This does not happen on Mac/Linux... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bjornrobertsson |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/coder/coder git https://github.com/coder/coder.git |
| octolytics-dimension-user_id | 95932066 |
| octolytics-dimension-user_login | coder |
| octolytics-dimension-repository_id | 440752086 |
| octolytics-dimension-repository_nwo | coder/coder |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 440752086 |
| octolytics-dimension-repository_network_root_nwo | coder/coder |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width