Skip to content

fix(ssh): include the Coder SSH config where Git for Windows ssh reads it - #1221

Merged
EhabY merged 3 commits into
mainfrom
fix/vsc-58-ssh-home-from-homedrive
Dec 2, 2026
Merged

EhabY merged 3 commits into
mainfrom
fix/vsc-58-ssh-home-from-homedrive

Conversation

@EhabY

@EhabY EhabY commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Part of VSC-58

Follow-up to #1211, which didn't fix VSC-58. With HOME unset, Git for Windows ssh takes its home from HOMEDRIVE+HOMEPATH, which a domain home folder sets to e.g. H:\. #1211 only checked HOME, so it kept the ~/AppData/... include and never wrote H:\.ssh\config. Git ssh read neither and got no ProxyCommand.

Stack: this PR → #1226 (Linux/macOS ssh home) → #1227 (SshConfig class to module functions).

Commits (review one at a time)

  1. 697c4a1 fix: the VSC-58 fix. prod +45/−62, tests +148/−133.
    • Include line: on Windows, write "/C:/..." "/c/...". Every Windows OpenSSH build from 7.6 reads /C:/ whatever HOME is, every Git for Windows build reads /c/, and each skips the other. This also fixes Windows OpenSSH 7.x (Server 2019) with HOME off the profile, and every Windows OpenSSH build with a non-ASCII HOME.
    • Git's own config: without -F, the same include block also goes into getGitForWindowsSshConfigPath(): Git's home is HOME (an MSYS /h read as H:\), else HOMEDRIVE+HOMEPATH, joined with .ssh\config. When that is the profile's config, the block is byte-identical, so the second write is a no-op.
  2. 96a19c0 review fixes: prod +127/−39, tests +200/−109.
    • ~/ by default: Windows OpenSSH reads /c/... as \c\... on the current drive, a folder any local user can create. So the include stays ~/... when HOME is unset, HOMEDRIVE+HOMEPATH name the profile (the logon default), and the data directory is under the profile. Other setups get both spellings, as in commit 1.
    • Timeout: the Git config write gives up after 5 s, since a domain home may be on an unreachable share.
    • Warning: when Remote-SSH's ssh resolves no ProxyCommand, a warning names the include directory and the config files ssh read, instead of failing silently. When ssh can't run, the silent fallback stays.
    • Fixed point: a config starting with whitespace is no longer rewritten on the second include.
    • Renames: getGitSshConfigPath becomes getGitForWindowsSshConfigPath, and DRIVE_PREFIX_REGEX becomes FORWARD_SLASH_DRIVE_REGEX.
    • Tests and docs: the Windows path tests now run on every platform, plus doc, comment and changelog fixes.

The /c/... spelling that setups outside the default still get is tracked in VSC-64.

Not covered: Cygwin with -F (no reports), MSYS2/Cygwin without -F (they read a config in their install folder, unchanged since v1.16.1), Git without -F when its home drive is unmapped or HOME is like /home/jane, Git 2.14–2.20 with -F in a non-ASCII profile, and a UNC data directory (untested with real ssh).

Windows test matrix

Windows Server 2025, two local users: jane (home folder on an SMB share mapped to H:) and Jörg Doe (space and non-ASCII profile). Each run used the extension's config-writing code in a fresh logon, then ssh -v -G with and without -F.

  • 43 builds: Win32-OpenSSH 7.6–10.4 (22 releases) plus the built-in 9.5; Git for Windows 2.14–2.56 (15 x64, 3 x86); MSYS2; Cygwin.
  • 14 home setups: nothing set; domain home; UNC home without a drive; HOME = H:\, H:/, h:\, /h, /h/, the profile (Windows and MSYS form), the UNC share (both slash styles), /home/<user>; home drive unmapped.
Setup v1.18.3 This PR
Domain home, HOME unset (customer) All Git fail All pass
UNC home, no drive letter All Git fail All pass
HOME=H:\ OpenSSH 7.6–7.9 fail All pass
HOME = non-ASCII profile All Windows OpenSSH fail All pass
HOME=/h OpenSSH 7.6–7.9 fail; Git fails without -F All pass
Nothing set; HOME = profile Pass Pass

The matrix ran on commit 1 (and on a refactored version of it, now in #1227). Commit 2 brings back v1.18.3's ~/... include for the "Nothing set" row, which passed there. It was not re-run on the matrix; locally, the real-binary tests pass against Windows OpenSSH 9.5 and Git ssh, including a new case with HOMEDRIVE+HOMEPATH at the profile and a non-ASCII HOME. Full suite, typecheck, lint and format pass on Windows.


🤖 Generated with Claude Code

@linear-code

linear-code Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

VSC-58

VSC-64

@EhabY
EhabY force-pushed the fix/vsc-58-ssh-home-from-homedrive branch from 7a11ef5 to a7d0113 Compare November 29, 2026 10:52
@EhabY
EhabY marked this pull request as ready for review November 29, 2026 11:54
@EhabY
EhabY force-pushed the fix/vsc-58-ssh-home-from-homedrive branch from af131df to d08099a Compare November 29, 2026 12:07
@EhabY
EhabY requested a review from jeremyruppel November 30, 2026 09:03
@EhabY

EhabY commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review

coder-agents-review Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Chat: Review posted | View chat
Requested: 2026-11-30 09:06 UTC by @EhabY
Spend: $13.07 / $100.00

Review history
  • R1 (2026-11-30): 12 reviewers, 4 Nit, 1 P2, 7 P3, 15 P4, COMMENT. Review

deep-review v0.13.1 | Round 1 | bd1241a..d08099a

Last posted: Round 1, 27 findings (1 P2, 7 P3, 15 P4, 4 Nit), COMMENT. Review

Finding inventory

Finding inventory: PR #1221

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 P3 Open test/unit/remote/remote.test.ts:624 Test names still say the Git config comes from HOME only R1 Netero Yes
CRF-2 P4 Open test/unit/remote/sshConfig.test.ts:340 Escape assertion dropped the Include prefix R1 Netero Yes
CRF-3 P4 Open test/unit/remote/sshConfig.test.ts:372 stubHomeEnv and env type duplicated across two test files R1 Netero Yes
CRF-4 P2 Open src/remote/sshConfig.ts:483 /c/ spelling makes Windows OpenSSH read a folder any local user can create under C:\ R1 Kurapika Yes
CRF-5 P3 Open src/remote/remote.ts:1008 Connect now does I/O on the network home share before ssh -G, even for Windows OpenSSH R1 Mafuuu P3, Hisoka P3, Pariston Note Yes
CRF-6 P3 Open src/remote/remote.ts:1029 "resolved no ProxyCommand" stays a silent log, so uncovered homes fail like VSC-58 R1 Pariston P3, Meruem OOS Yes
CRF-7 P4 Open src/remote/remote.ts:1007 mergeInclude is not idempotent with leading whitespace; "no write" comment is false R1 Mafuuu, Mafu-san Yes
CRF-8 P3 Open test/unit/remote/sshConfig.test.ts:442 Off-Windows test passes with the platform check removed R1 Bisky Yes
CRF-9 P3 Open test/unit/remote/sshConfig.openssh.test.ts:212 No real-binary case for the non-ASCII fix R1 Bisky Yes
CRF-10 P4 Open test/unit/remote/sshConfig.test.ts:383 Pure string-logic cases run only on Windows hosts R1 Bisky Yes
CRF-11 P4 Open test/unit/remote/sshConfig.test.ts:367 readSpy assertion checks internal step order R1 Bisky Yes
CRF-12 Note Dropped by orchestrator (positive confirmation, asks no change) test/unit/remote/sshConfig.openssh.test.ts:223 Git real-binary cases test real behavior R1 Bisky No
CRF-13 P3 Open src/remote/sshConfig.ts:360 permissions docs call Coder's own file unmanaged off Windows R1 Gon P3, Zoro P4, Meruem Nit Yes
CRF-14 P2 Dropped by orchestrator (merged into CRF-13, same wrong meaning) src/remote/sshConfig.ts:357 CoderSshConfigFile doc "whether Coder manages it" R1 Gon No
CRF-15 P4 Open src/remote/sshConfig.ts:371 CoderSshInclude doc implies a per-deployment include R1 Gon P2 Yes
CRF-16 P2 Dropped by orchestrator (rationale belongs at the definition per repo rule) src/remote/sshConfig.ts:470 includeArguments doc restates branches R1 Gon No
CRF-17 P2 Dropped by orchestrator (doc is accurate; restating is not wrong) src/remote/sshConfig.ts:544 writeSshConfig doc restates code R1 Gon No
CRF-18 P2 Dropped by orchestrator (verbatim moved comment, accurate) src/remote/sshConfig.ts:568 getFileMode doc restates code R1 Gon No
CRF-19 P2 Dropped by orchestrator (verbatim moved comment, accurate) src/remote/sshConfig.ts:606 writeTemp doc duplicates inner comment R1 Gon No
CRF-20 P2 Dropped by orchestrator (verbatim moved comment, accurate) src/remote/sshConfig.ts:641 replaceWithTemp doc restates catch R1 Gon No
CRF-21 Nit Open src/remote/remote.ts:1005 Call-site comment repeats the Git home rule R1 Gon P2 Yes
CRF-22 P4 Open src/remote/remote.ts:912 "One file per..." comment sits far from the file it describes R1 Gon P3 Yes
CRF-23 P4 Open src/remote/sshConfig.ts:393 @throws incomplete on writeCoderSshConfig, missing on includeCoderSshConfig R1 Gon, Leorio Yes
CRF-24 P4 Open test/unit/remote/sshConfig.openssh.test.ts:222 Comment says Git ssh reads only ~/.ssh/config R1 Gon Yes
CRF-25 Nit Open test/unit/remote/sshConfig.openssh.test.ts:249 Duplicate 10_000 ssh -G timeout literal R1 Gon P4 Yes
CRF-26 Nit Open test/unit/remote/sshConfig.test.ts:114 Test helpers keep removed method names R1 Gon Yes
CRF-27 Nit Open test/unit/remote/sshSupport.test.ts:22 Four dots in comment R1 Gon Yes
CRF-28 Note Dropped by orchestrator (audit record, asks no change) src/remote/sshConfig.ts:66 Other comments kept R1 Gon No
CRF-29 P4 Open src/remote/remote.ts:1014 Git config write warning omits the consequence R1 Leorio P3 Yes
CRF-30 P4 Open src/remote/sshConfig.ts:95 Doc says HOMEDRIVE+HOMEPATH comes from a domain home; Windows always sets it R1 Leorio Yes
CRF-31 P4 Dropped by orchestrator (merged into CRF-23) src/remote/sshConfig.ts:411 includeCoderSshConfig lacks @throws R1 Leorio No
CRF-32 P4 Open docs/ARCHITECTURE.md:59 "two spellings" false for a UNC data dir R1 Leorio Yes
CRF-33 P4 Open CHANGELOG.md:12 Changelog omits UNC home and MSYS HOME fixes R1 Leorio Yes
CRF-34 Note Note (body) PR title Title says "every Windows ssh home"; Not covered list says otherwise R1 Leorio P4 No
CRF-35 P4 Open CHANGELOG.md:12 "connect again" claims a prior working release without evidence R1 Mafu-san P3 Yes
CRF-36 Note Dropped by orchestrator (praise, asks no change) PR description Description explains reasoning R1 Leorio No
CRF-37 P4 Open src/remote/sshConfig.ts:477 UNC "both read" claim untested R1 Mafu-san P3 Yes
CRF-38 P3 Open src/remote/sshConfig.ts:379 Refactor ships with the fix in one squash commit R1 Mafu-san Yes
CRF-39 Note Dropped by orchestrator (trust-signal record, asks no change) test/unit/remote/sshConfig.openssh.test.ts:223 Process trust signals R1 Mafu-san No
CRF-40 Note Dropped by orchestrator (asks no change) src/remote/sshConfig.ts:100 Rewrite removes dead home detection R1 Zoro No
CRF-41 P3 Dropped by orchestrator (ssh -v logs only files it opened; absent Git config never appears, verified with OpenSSH 10.2) src/remote/sshConfig.ts:100 Derive Git config path from ssh -v output R1 Meruem No
CRF-42 OOS Out of scope (body) src/remote/sshConfig.ts:116 #1211 already wrote /c/ for data dirs outside the profile R1 Kurapika No
CRF-43 OOS Out of scope (body) src/remote/sshConfig.ts:486 Off Windows, ~ include uses Node HOME; OpenSSH uses passwd home R1 Melody No
CRF-44 OOS Out of scope (body) src/remote/remote.ts:985 Concurrent connects race on read-modify-write of configs R1 Mafuuu No
CRF-45 OOS Out of scope (body) src/remote/sshConfig.ts:41 ManagedPermissions doc has the same unmanaged wording R1 Gon No
CRF-46 OOS Out of scope (body) src/remote/sshConfig.ts:63 DRIVE_PREFIX_REGEX name hides forward-slash requirement R1 Gon No
CRF-47 OOS Out of scope (body) src/remote/sshConfig.ts:61 DRIVE_OR_UNC_PATH_REGEX and isFullyQualifiedWindowsPath duplicate with different rules R1 Zoro No
CRF-48 OOS Dropped by orchestrator (duplicate of CRF-37) src/remote/sshConfig.ts:479 UNC %APPDATA% on Windows OpenSSH 7.x unverified R1 Mafu-san No
CRF-49 OOS Dropped by orchestrator (duplicate of CRF-6) src/remote/remote.ts:1027 Silent fallback when ssh -G resolves no ProxyCommand R1 Meruem No

Contested and acknowledged

Round log

Round 1

Full panel (round 1). Netero first pass: 1 P3, 2 P4, no P0. Law not run (589 effective additions). Panel: ging-ts, kurapika, melody, pariston, mafuuu, bisky, hisoka, gon, leorio, mafu-san, zoro, plus wildcard meruem (random from distilled set). Posted 1 P2, 7 P3, 15 P4, 4 Nit; 6 OOS in body; 1 Note in body; 13 dropped or merged. Pariston rejected the ssh -v alternative (CRF-41); orchestrator confirmed with sudo -u nobody ssh -v -G foo, which logs no line for the absent user config. Reviewed against bd1241a..d08099a.

About deep-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Komugi flake/determinism
Kurapika security
Law decomposition
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR writes the Windows Include as /C:/... plus /c/..., adds the Include to Git for Windows' own config found from HOME or HOMEDRIVE+HOMEPATH, and replaces the SshConfig class with functions. Findings: 1 P2, 7 P3, 15 P4, 4 Nit.

The PR title says "every Windows ssh home", but the description's Not covered list excludes some Git homes, and the squash merge makes the title the commit subject. A narrower subject: fix(ssh): include the Coder SSH config where Git for Windows ssh reads it.

Out of scope (needs a ticket or explicit acceptance by a human):

  • src/remote/sshConfig.ts:116: since #1211, a data directory outside the profile already got the /c/... spelling, so the shadow-folder problem in the P2 finding predates this PR for that setup.
  • src/remote/sshConfig.ts:486: off Windows, the ~/ include is relative to os.homedir(), which Node takes from HOME, while OpenSSH expands ~ from the passwd entry (confirmed with OpenSSH 10.2 and HOME pointing elsewhere); when they differ, ssh does not find the Coder files.
  • src/remote/remote.ts:985: two windows connecting at once both read-modify-write the profile and Git configs with no lock, so one window's include or legacy-block removal can be lost.
  • src/remote/sshConfig.ts:41: the ManagedPermissions doc says a config without one is not Coder-managed, which is wrong off Windows in the same way as the permissions field doc.
  • src/remote/sshConfig.ts:63: the name DRIVE_PREFIX_REGEX does not say it matches only forward-slashed drives, so a caller that skips the backslash conversion gets no match.
  • src/remote/sshConfig.ts:61: DRIVE_OR_UNC_PATH_REGEX and isFullyQualifiedWindowsPath in windowsAcl.ts both test for a drive or UNC path with different rules, so a change to one does not reach the other.

test/unit/remote/remote.test.ts:624

P3 [CRF-1] The describe block "HOME ssh config on Windows" and the helper writeWithHomeConfig still say Git's config comes from HOME, but getGitForWindowsSshConfigPath now also uses HOMEDRIVE+HOMEPATH, which is the case this PR fixes. (Netero)

Rename them for the Git for Windows config, for example "Git for Windows ssh config", writeWithGitConfig, and gitConfig.

🤖

🤖 This review was automatically generated with Coder Agents.

Comment thread test/unit/remote/sshConfig.test.ts Resolved
Comment thread test/unit/remote/sshConfig.test.ts Resolved
Comment thread src/remote/sshConfig.ts Resolved
Comment thread src/remote/remote.ts Resolved
Comment thread src/remote/remote.ts Resolved
Comment thread docs/ARCHITECTURE.md Resolved
Comment thread CHANGELOG.md Resolved
Comment thread CHANGELOG.md Resolved
Comment thread src/remote/sshConfig.ts Resolved
Comment thread src/remote/sshConfig.ts Resolved
@EhabY EhabY changed the title fix(ssh): include the Coder SSH config for every Windows ssh home fix(ssh): include the Coder SSH config where Git for Windows ssh reads it Nov 30, 2026
@EhabY

EhabY commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator Author

CRF-1 fixed in 5d1efe2 (renamed to "Git for Windows ssh config", writeWithGitConfig, gitConfig), and the title is renamed as suggested. The out-of-scope items are being triaged separately.

@EhabY

EhabY commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator Author

Split into a stack: this PR is now only the Git for Windows fix, followed by #1226 (Linux/macOS ssh home, the out-of-scope os.homedir() finding) and #1227 (the class to module refactor, per CRF-38). The review fixes referenced as 5d1efe2 in the thread replies are now 96a19c0, rewritten against the class. The /c/... spelling outside the default setup is tracked in VSC-64.

@EhabY
EhabY added this pull request to stack #1228 November 30, 2026 10:22
@EhabY
EhabY force-pushed the fix/vsc-58-ssh-home-from-homedrive branch from 96a19c0 to 233b6dc Compare December 1, 2026 22:07
Comment thread test/utils/platform.ts Resolved

@jeremyruppel jeremyruppel left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approving in advance of the test fixup 👍

EhabY added 3 commits December 2, 2026 13:22
With HOME unset, Git for Windows ssh takes its home from HOMEDRIVE and
HOMEPATH, which a domain home folder sets to e.g. H:\. v1.18.3 only looked
at HOME, so it kept the ~/AppData/... include and wrote nothing to
H:\.ssh\config: Git ssh read neither and got no ProxyCommand.

- On Windows, write the include as "/C:/..." "/c/...". Every Windows
  OpenSSH build from 7.6 reads /C:/ whatever HOME is, every Git for
  Windows build reads /c/, and each skips the other. This drops the ~/
  guess and getSshHomeDir.
- Without -F, also include the block in the config Git ssh reads: HOME
  (an MSYS /h read as H:\), else HOMEDRIVE+HOMEPATH. The block is
  byte-identical everywhere, so when that is the profile's config the
  second write is a no-op.

Refs VSC-58
- Keep the ~/ include when HOME is unset and every build's home is the
  profile: Windows OpenSSH reads /c/... as \c\... on the current drive,
  which any local user can create.
- Bound the Git config write with a 5 second timeout, since a domain home
  may be on an unreachable share.
- Warn when Remote-SSH's ssh resolves no ProxyCommand, naming the include
  directory and the config files ssh read.
- Trim leading whitespace in mergeInclude so a second include is a no-op.
- Rename getGitSshConfigPath to getGitForWindowsSshConfigPath and
  DRIVE_PREFIX_REGEX to FORWARD_SLASH_DRIVE_REGEX.
- Run the Windows path tests on every platform, share the home env test
  helpers, and fix docs, comments and the changelog.
@EhabY
EhabY force-pushed the fix/vsc-58-ssh-home-from-homedrive branch from 233b6dc to 78ed373 Compare December 2, 2026 10:24
@EhabY
EhabY merged commit 0e2d42f into main Dec 2, 2026
18 checks passed
@EhabY
EhabY deleted the fix/vsc-58-ssh-home-from-homedrive branch December 2, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants