@zhangfengshun/dsh-remote-ssh 2.3.8 → 2.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  本文件的版本号与 `package.json` 的 `version` 保持一致。每个版本对应一个 Cordis Package 快照(`pkg-N`)。
4
4
 
5
+ ## [2.3.9] — 修复 git-bash 启动导致的密钥认证失败(ssh 解析钉定到系统 OpenSSH)
6
+ ### 修复
7
+ - **Windows 下 ssh 可执行文件优先解析为系统自带 OpenSSH 的绝对路径**(`%SystemRoot%\System32\OpenSSH\ssh.exe`,存在才使用,否则回落 PATH):此前从 **git-bash** 启动 `dsh web` 时,子进程 PATH 里 Git 自带的 MSYS2 ssh 排在系统 OpenSSH 之前,插件实际调用 Git 的 ssh——其 HOME/config/agent 语义与系统 OpenSSH 不同,导致"终端能连、测试连接 Permission denied"。ssh 主机侧忽略用户 authorized_keys 的 HPC 集中授权环境同样受此影响。
8
+ - **终端 shell wrapper 同步修复**:生成的 `dsh-remote-shell.js` 同样优先解析系统 OpenSSH 绝对路径。
9
+ - 非 Windows 平台、未安装系统 OpenSSH 的环境:行为与之前完全一致(回落 PATH),零破坏。
10
+
5
11
  ## [2.3.8] — `/remote-ssh/api` CSRF 加固(合并 PR #4 + 服务端强制校验)
6
12
  ### 安全
7
13
  - **合并 PR #4**(感谢 @anupamme / OrbisAI Security):客户端 API 调用(`/remote-ssh/api/*`)统一携带 `x-requested-with: XMLHttpRequest` 头。
package/lib/index.js CHANGED
@@ -336,8 +336,22 @@ class CommandSession {
336
336
  }
337
337
  }
338
338
 
339
+ /** Windows 下优先解析系统自带 OpenSSH 的绝对路径:从 git-bash 启动 dsh web 时,
340
+ * 子进程 PATH 会把 Git 自带的 MSYS2 ssh 排在系统 OpenSSH 之前(HOME/config/agent
341
+ * 语义不同,导致密钥认证失败——issue:git-bash 启动场景)。System32\OpenSSH 是
342
+ * Win10 1809+ 的标准安装位置,不存在则回落 PATH(维持旧行为)。结果模块级缓存。 */
343
+ let cachedSshPath;
344
+ function sshExecutablePath() {
345
+ if (cachedSshPath !== undefined) return cachedSshPath;
346
+ if (process.platform === "win32") {
347
+ const sysSsh = join(process.env.SystemRoot || "C:\\Windows", "System32", "OpenSSH", "ssh.exe");
348
+ if (existsSync(sysSsh)) return (cachedSshPath = sysSsh);
349
+ }
350
+ return (cachedSshPath = "ssh");
351
+ }
352
+
339
353
  function sshArgv(p, remoteCmd, tty, extraOpts) {
340
- const opts = ["ssh"];
354
+ const opts = [sshExecutablePath()];
341
355
  if (tty) opts.push("-tt");
342
356
  opts.push("-p", String(p.port || 22));
343
357
  opts.push("-o", "StrictHostKeyChecking=accept-new");
@@ -1854,10 +1868,13 @@ function apply(ctx, config) {
1854
1868
  " const j = JSON.parse(fs.readFileSync(info, 'utf8'));",
1855
1869
  " if (j.keyPath && j.keyPath !== '' && j.host && j.user) {",
1856
1870
  " const port = j.port || 22;",
1871
+ " // Windows 下优先解析系统自带 OpenSSH 绝对路径(避免 git-bash 启动时解析到 MSYS2 ssh)",
1872
+ " const sysSsh = path.join(process.env.SystemRoot || 'C:\\\\Windows', 'System32', 'OpenSSH', 'ssh.exe');",
1873
+ " const sshBin = fs.existsSync(sysSsh) ? sysSsh : 'ssh';",
1857
1874
  " // ExitOnForwardFailure=no:ssh config 里的 RemoteForward 端口被占时终端仍能打开",
1858
1875
  " const args = ['-tt', '-o', 'StrictHostKeyChecking=no', '-o', 'ExitOnForwardFailure=no', '-p', String(port), '-i', j.keyPath, j.user + '@' + j.host];",
1859
1876
  " if (j.proxyJump) { args.splice(2, 0, '-J', j.proxyJump); }",
1860
- " const ssh = spawn('ssh', args, { stdio: 'inherit' });",
1877
+ " const ssh = spawn(sshBin, args, { stdio: 'inherit' });",
1861
1878
  " ssh.on('exit', function(c) { process.exit(c == null ? 0 : c); });",
1862
1879
  " return;",
1863
1880
  " }",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhangfengshun/dsh-remote-ssh",
3
- "version": "2.3.8",
3
+ "version": "2.3.9",
4
4
  "description": "DSH web plugin: VSCode Remote-SSH-like remote development (SSH to supercomputers/servers, remote workspace, file explorer, integrated terminal), integrated with dsh-better-sidebar and DSH settings.",
5
5
  "keywords": [
6
6
  "dsh",