@linxin666/dsh-ssh 0.4.18 → 0.4.20

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/README.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # node scripts/verify-docs.mjs --write <dir>
5
- README.md: 716d0c18087aa498b939f9e80acfb80666444aef
6
- README.zh.md: 439f42a772a7627ee562cebd98598ea24e2f7ea5
5
+ README.md: 72c0ae85e0420563887ceea4d6a248a8f73d1e84
6
+ README.zh.md: 60e6f45414ac1a9f7a2d2f924c6726ab09540926
package/README.md CHANGED
@@ -5,7 +5,7 @@ English | [中文](README.zh.md)
5
5
  <p align="center">
6
6
  <img src="https://img.shields.io/npm/v/@linxin666/dsh-ssh?style=flat-square" alt="Version">
7
7
  &nbsp;
8
- <img src="https://img.shields.io/badge/DSH-%3E%3D0.2.2--rc.2-4c6ef5?style=flat-square&amp;labelColor=454a54" alt="DSH">
8
+ <img src="https://img.shields.io/badge/DSH-%3E%3D0.2.2--rc.3-4c6ef5?style=flat-square&amp;labelColor=454a54" alt="DSH">
9
9
  &nbsp;
10
10
  <img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
11
11
  </p>
@@ -22,6 +22,7 @@ A dedicated remote Linux server operations and cluster management plugin for Dee
22
22
  | Capability | Description |
23
23
  | --- | --- |
24
24
  | Host management | CRUD, search, connection test; collapsible grouping by environment / tags with per-group batch test; config stored in `~/.dsh/dsh-ssh.json`; supports key / password / ssh-agent auth (OpenSSH agent, with Pageant still selectable on Windows), passphrase keys, ProxyJump jump hosts (multi-level) and OpenSSH `ProxyCommand` transports (bastion clients) |
25
+ | Managed keys | The Keys tab registers a name, absolute local private-key path, optional passphrase and note. Rows show file existence and referencing hosts. The host form offers managed keys plus a custom-path option, auto-matches legacy hand-written paths, and resolves an explicitly selected key's path/passphrase Host-side without returning the managed passphrase to the browser. Only metadata is statted; private-key contents are never read or copied |
25
26
  | Config import | One-click parse of a standard `~/.ssh/config` (Host/HostName/User/Port/IdentityFile/IdentityAgent/ForwardAgent/ProxyJump/ProxyCommand, `Include` files, blocks without HostName); `ForwardAgent yes|true|on` imports as enabled and `no|false|off` (or no directive) as disabled; skipped blocks are listed with their reason (wildcard pattern, existing alias, Match block, invalid fields) |
26
27
  | Persistent connection pool | Reuses a long-lived connection per host (opposite of the ssh-skill daemon), automatically disconnects after 30 minutes idle, auto-reconnects on disconnect (up to 3 times) |
27
28
  | Agent forwarding | Opt-in per host through the `forwardAgent` flag (`ssh -A`); the form has an "Enable agent forwarding" checkbox, the host list shows an agent-forwarding badge for enabled hosts, and `ssh_list` reports `forwardAgent` with a forward column in its table. The endpoint is the host's configured agent path, otherwise `SSH_AUTH_SOCK`, otherwise the native OpenSSH named pipe (`\\.\pipe\openssh-ssh-agent`) on Windows; a host with no local endpoint fails with an explicit error instead of connecting without forwarding. A server that refuses the request (`AllowAgentForwarding no`) surfaces its own error and is never downgraded to a silent non-forwarded session. The flag never touches the stored profile when it is off |
@@ -34,9 +35,17 @@ A dedicated remote Linux server operations and cluster management plugin for Dee
34
35
 
35
36
  The panel loads its contents on first open. Closing and reopening it preserves the selected tab, form drafts and every terminal tab. A terminal tab that is not on screen keeps its remote shell in the Host: the view detaches, and returning to the tab reattaches by session id and replays the host's scrollback into the single xterm. A remote shell that exits keeps its tab and its last screen instead of vanishing, and a tab closed in the background is only removed once the Host confirms the close — a close that cannot be delivered keeps the tab and says so. The tunnel list refreshes every five seconds while its tab, panel and browser page are visible; automatic reads pause when hidden, resume immediately on return, and do not overlap slow reads. Port forwarding itself continues in the Host.
36
37
 
38
+ ## Sibling-plugin service
39
+
40
+ The host half publishes one cordis service, `dshSsh` (`DSH_SSH_API_VERSION = 1`), so another plugin running in the same DSH host reuses this plugin's host inventory and connection pool instead of keeping a second one: `hosts.list()`, `hosts.find(alias)`, `exec(alias, command, { timeoutMs, signal })`, `upload(alias, localPath, remotePath)` and `download(alias, remotePath, localPath)`. A consumer injects it with `ctx.inject(['dshSsh'], ...)` and restates the types from `src/service.ts`; it never imports this package.
41
+
42
+ The face is a thin forwarder over the engine that serves the panel, the web terminal and the `ssh_*` tools, so a consumer shares the pooled connection, the connection ceiling and the host store with them. It keeps no state of its own and exposes no terminal, tunnel, cluster or streaming member: a log a consumer has to replay is a remote file it reads by offset through `exec`.
43
+
44
+ The service is published only while the master switch is on, and it is withdrawn with the plugin: turning the switch off or unloading the plugin unloads every dependent's inject scope, so no consumer keeps operating hosts on behalf of a plugin the user turned off.
45
+
37
46
  ## Security model
38
47
 
39
- - All `/api/dsh-ssh/*` routes are loopback-only (with same-origin checks) — the interfaces that execute commands against remote servers are not exposed to the LAN.
48
+ - `/api/dsh-ssh/*` and the terminal upgrade admit requests accepted by the Host `connection` service (authenticated/trusted-host reverse proxy) or by strict loopback + same-origin checks. Remote access requires the Host's own `--trusted-host` configuration; forwarding headers alone never grant access, and a rejected or unavailable connection decision leaves the loopback fence unchanged.
40
49
  - Passwords / key passphrases are stored in plain text in `~/.dsh/dsh-ssh.json`, file mode 0600, directory 0700 (the same trust model as ssh-skill writing passwords into ssh-config comments).
41
50
  - ssh-agent auth stores only the agent socket path (or the special value `pageant`); it never reads or stores private-key material. An empty agent path is not a secret and is always saved: it means auto-detect (`SSH_AUTH_SOCK`, then the native OpenSSH named pipe on Windows), so switching a host to SSH Agent takes effect even with the field left blank.
42
51
  - Agent forwarding is opt-in per host and off by default. With `forwardAgent` enabled, every exec and PTY session on that host asks the server for `auth-agent-req@openssh.com`, which means the remote host can authenticate as this machine with your local keys. Enable it only for hosts you trust, and remember every session on such a host can use the forwarded agent. When no agent endpoint resolves (the configured agent path, `SSH_AUTH_SOCK`, the native OpenSSH named pipe on Windows) the connection fails instead of forwarding nothing, and a server that refuses the request surfaces its error exactly as it comes back.
@@ -48,6 +57,7 @@ The panel loads its contents on first open. Closing and reopening it preserves t
48
57
  - `ssh_upload` / `ssh_download` read/write arbitrary local paths on this machine with host-process privileges (not through the bash sandbox) — same host-local-path semantics as ssh-skill, be aware of that permission surface.
49
58
  - Agent transfer tools move files only between this machine and a remote SSH host; local-file reads and writes must use the local file tools (read / write / edit / bash), never the `ssh_*` tools.
50
59
  - The remote output of exec / cluster is returned verbatim (not sanitized); a command like `env` may bring secrets from the remote environment back into the conversation log.
60
+ - `dshSsh` is a host-process service, not a network surface: any plugin loaded into this host can execute commands and transfer files on the configured hosts through it, with the same reach as the `ssh_*` tools and no per-consumer permission. What it never hands out is credential material — `hosts.list()` and `hosts.find()` return the public host fields only, with no password, passphrase, private-key path, agent path or `proxyCommand` text.
51
61
 
52
62
  ## Install
53
63
 
@@ -73,7 +83,7 @@ The settings panel (plugin config) toggles `announceToAgent` (whether to announc
73
83
 
74
84
  ## Data
75
85
 
76
- - Host config: `~/.dsh/dsh-ssh.json` (versioned JSON, atomic write)
86
+ - Host and managed-key config: `~/.dsh/dsh-ssh.json` (versioned JSON, atomic write; incremental `keys` collection appears only after the first managed key is added)
77
87
  - Transfer staging: `os.tmpdir()/dsh-ssh-uploads/` (0700 directory, 0600 in-flight files)
78
88
 
79
89
  ## Development
@@ -86,6 +96,7 @@ pnpm --filter @linxin666/dsh-ssh build # tsc types + tsdown dual-half artifact
86
96
 
87
97
  ## Known limitations
88
98
 
99
+ - Editing or deleting a managed key changes only its managed record. Existing host `auth.keyPath` / passphrase values and private-key files are never rewritten or deleted; confirmations name every referencing host, and a host whose path no longer matches remains a custom-path entry.
89
100
  - The remote target path of an upload must be an absolute path (relative paths are rejected).
90
101
  - Download does not support a whole directory yet (download files individually); upload supports recursive directories (walks the local directory and transfers file by file).
91
102
  - exec auto-reconnect on disconnect (up to 3 times) may re-execute non-idempotent commands — watch out for side effects on long commands.
package/README.zh.md CHANGED
@@ -5,7 +5,7 @@
5
5
  <p align="center">
6
6
  <img src="https://img.shields.io/npm/v/@linxin666/dsh-ssh?style=flat-square" alt="Version">
7
7
  &nbsp;
8
- <img src="https://img.shields.io/badge/DSH-%3E%3D0.2.2--rc.2-4c6ef5?style=flat-square&amp;labelColor=454a54" alt="DSH">
8
+ <img src="https://img.shields.io/badge/DSH-%3E%3D0.2.2--rc.3-4c6ef5?style=flat-square&amp;labelColor=454a54" alt="DSH">
9
9
  &nbsp;
10
10
  <img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
11
11
  </p>
@@ -22,6 +22,7 @@
22
22
  | 能力 | 说明 |
23
23
  | --- | --- |
24
24
  | 主机管理 | 增删改查、搜索、连接测试;支持按环境 / 标签分组折叠与组内批量测试;配置存 `~/.dsh/dsh-ssh.json`;支持密钥 / 密码 / ssh-agent 认证(OpenSSH agent,Windows 上仍可选 Pageant)、passphrase 密钥、ProxyJump 跳板机(多级)与 OpenSSH `ProxyCommand` 传输层(堡垒机客户端场景) |
25
+ | 受管密钥 | 「密钥」页签登记名称、本机私钥绝对路径、可选口令与备注,列表显示文件是否存在及引用主机。主机表单提供受管密钥下拉框与自定义路径,旧的手填路径自动匹配;显式选择后由宿主侧解析路径与口令,不向浏览器回读受管口令。只读取文件元数据,绝不读取或复制私钥内容 |
25
26
  | 配置导入 | 一键解析标准 `~/.ssh/config`(Host/HostName/User/Port/IdentityFile/IdentityAgent/ForwardAgent/ProxyJump/ProxyCommand、`Include` 文件、无 HostName 的块);`ForwardAgent yes|true|on` 导入为启用,`no|false|off` 或没有该指令导入为关闭;被跳过的块逐条列出原因(通配符 pattern、别名已存在、Match 条件块、字段不合法) |
26
27
  | 持久连接池 | 每台主机复用长连接(对应 ssh-skill 的守护进程),空闲 30 分钟自动断开,断线自动重连(最多 3 次) |
27
28
  | Agent 转发 | 按主机选择性启用(`ssh -A`):主机表单提供「启用 Agent 转发」勾选框,主机列表为已启用的主机显示「Agent 转发」标记;`ssh_list` 输出带 `forwardAgent`,渲染表格中对应一列。转发的本地端点依次取主机配置的 agent 路径、`SSH_AUTH_SOCK`、Windows 上的原生 OpenSSH 命名管道(`\\.\pipe\openssh-ssh-agent`);三者都拿不到时连接直接报错,不会静默地不转发。服务端拒绝该请求(`AllowAgentForwarding no`)时原样呈现服务端错误,绝不静默降级为未转发的会话。关闭时不写入配置文件 |
@@ -34,9 +35,17 @@
34
35
 
35
36
  面板在首次打开时加载内容。关闭后重新打开会保留选中的页签、表单草稿与全部终端标签。不在前台的终端标签仍由 Host 保活:视图只做 detach,切回该标签时按 session id 重新 attach,并把 Host 的滚动缓冲回放进同一个 xterm。远端 shell 退出后标签与最后一屏内容保留、不会消失;关闭后台标签只在 Host 确认关闭后才移除标签,关闭帧送不到 Host 时标签保留并给出提示。隧道列表仅在隧道页签、面板和浏览器页面都可见时每五秒刷新;隐藏时暂停自动查询,恢复可见时立即刷新,慢查询期间不叠加请求。端口转发本身继续在 Host 中运行。
36
37
 
38
+ ## 跨插件服务
39
+
40
+ 宿主半区发布一个 cordis 服务 `dshSsh`(`DSH_SSH_API_VERSION = 1`),同一 DSH 宿主进程内的其他插件因此可以直接复用本插件的主机清单与连接池,而不必自建一套:`hosts.list()`、`hosts.find(alias)`、`exec(alias, command, { timeoutMs, signal })`、`upload(alias, localPath, remotePath)`、`download(alias, remotePath, localPath)`。消费方用 `ctx.inject(['dshSsh'], ...)` 注入,并从 `src/service.ts` 同形重述类型;它不 import 本包。
41
+
42
+ 该服务面是面板、Web 终端与 `ssh_*` 工具所共用引擎的薄转发,因此消费方与它们共享同一份池化连接、同一个连接上限与同一份主机配置。它自身不持有状态,也不提供终端、隧道、集群与流式成员:消费方需要回放的日志是远端的文件,由它按字节偏移经 `exec` 读取。
43
+
44
+ 服务只在总开关打开期间发布,并随插件一同撤走:关闭开关或卸载插件都会卸载每个依赖方的 inject 作用域,用户关掉的插件不会留下仍在操作主机的消费方。
45
+
37
46
  ## 安全模型
38
47
 
39
- - 所有 `/api/dsh-ssh/*` 路由仅限 loopback 访问(含同源校验)——对远程服务器执行命令的接口不会暴露给局域网。
48
+ - `/api/dsh-ssh/*` 与终端 upgrade 优先采用宿主 `connection` 服务的准入判定(已认证 / trusted-host 反向代理),否则沿用严格的 loopback + 同源校验。远程访问必须配置宿主自己的 `--trusted-host`;转发头本身绝不构成放行依据,宿主拒绝或无法裁决时原回环围栏保持不变。
40
49
  - 密码 / 密钥口令以明文保存在 `~/.dsh/dsh-ssh.json`,文件权限 0600、目录 0700(与 ssh-skill 把密码写进 ssh-config 注释同一信任模型)。
41
50
  - ssh-agent 认证仅保存 agent socket 路径(或 `pageant` 特殊值),不读取也不保存任何私钥材料。空的 agent 路径不是机密,任何时候都会提交:它表示自动检测(`SSH_AUTH_SOCK`,Windows 上再退到原生 OpenSSH 命名管道),因此把主机改成 SSH Agent 后即使路径留空也会生效。
42
51
  - Agent 转发是按主机选择性启用的能力,默认关闭。启用 `forwardAgent` 后,该主机上的每个 exec 与 PTY 会话都会向服务端请求 `auth-agent-req@openssh.com`,这意味着远端主机可以用你本机的密钥以这台机器的身份完成认证。只为你信任的主机启用,并记住这类主机上的每个会话都能使用被转发的 agent。本地端点(主机配置的 agent 路径、`SSH_AUTH_SOCK`、Windows 上的原生 OpenSSH 命名管道)解析不出来时连接直接失败,而不是什么都不转发;服务端拒绝该请求时,其错误原样呈现。
@@ -48,6 +57,7 @@
48
57
  - `ssh_upload` / `ssh_download` 以宿主进程权限直接读写本机任意路径(不经 bash 沙箱)——与 ssh-skill 的宿主本地路径语义一致,注意该权限面。
49
58
  - Agent 传输工具只在本机与远程 SSH 主机之间移动文件;本机文件的读写一律使用本地文件工具(read / write / edit / bash),不要使用 `ssh_*` 工具。
50
59
  - exec / cluster 的远程输出原样返回(不脱敏),命令如 `env` 可能把远端环境中的密钥带回对话记录。
60
+ - `dshSsh` 是宿主进程内的服务,不是网络面:装载进本宿主的任何插件都能经它执行远程命令、传输文件,可达范围与 `ssh_*` 工具相同,且没有按消费方的权限分级。它绝不交出凭据材料——`hosts.list()` 与 `hosts.find()` 只返回主机的公开字段,不含密码、口令、私钥路径、agent 路径与 `proxyCommand` 原文。
51
61
 
52
62
  ## 安装
53
63
 
@@ -73,7 +83,7 @@ dsh plugin --profile web add link:$(pwd)/packages/dsh-ssh
73
83
 
74
84
  ## 数据
75
85
 
76
- - 主机配置:`~/.dsh/dsh-ssh.json`(版本化 JSON,原子写入)
86
+ - 主机与受管密钥配置:`~/.dsh/dsh-ssh.json`(版本化 JSON,原子写入;新增首个受管密钥时才增加增量 `keys` 集合)
77
87
  - 传输暂存:`os.tmpdir()/dsh-ssh-uploads/`(目录 0700,传输中的文件 0600)
78
88
 
79
89
  ## 开发
@@ -86,6 +96,7 @@ pnpm --filter @linxin666/dsh-ssh build # tsc 类型 + tsdown 双半区产物
86
96
 
87
97
  ## 已知限制
88
98
 
99
+ - 修改或删除受管密钥只改变受管记录,绝不改写或删除既有主机的 `auth.keyPath` / 口令与私钥文件;确认框列出全部引用主机,路径不再匹配的主机保留为自定义路径。
89
100
  - 上传的远程目标路径必须是绝对路径(相对路径会被拒绝)。
90
101
  - 下载暂不支持整个目录(逐文件下载);上传支持目录递归(walk 本地目录逐文件传)。
91
102
  - exec 断线自动重连(最多 3 次)可能重复执行非幂等命令——长命令注意副作用。