mcp-ssh-manager 3.7.0 → 3.8.1
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 +59 -1
- package/CLAUDE.md +35 -0
- package/CONTRIBUTING.md +21 -5
- package/README.md +61 -11
- package/cli/install.sh +6 -0
- package/cli/lib/menu.sh +39 -5
- package/cli/ssh-manager +18 -2
- package/package.json +11 -6
- package/src/backup-manager.js +1 -1
- package/src/config-loader.js +51 -0
- package/src/database-manager.js +5 -4
- package/src/index.js +92 -17
- package/src/rsync-path.js +73 -0
- package/src/server-config-manager.js +11 -0
- package/src/server-groups.js +182 -55
- package/src/session-manager.js +3 -3
- package/src/ssh-manager.js +5 -4
- package/src/tunnel-manager.js +40 -16
- package/tsconfig.json +36 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,64 @@ All notable changes to MCP SSH Manager will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [3.8.1] - 2026-08-28
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`package-lock.json` is now committed** (contributed by @cudatuda in #60) — installs are reproducible, `npm ci` works, and the transitive tree is auditable. npm excludes lockfiles from published tarballs, so consumers of the package are unaffected.
|
|
13
|
+
- **`npm run test:lockfile`** (`tests/test-lockfile.js`, wired into `npm test`) — guards the lockfile against the ways it rots: version drift between `package.json` and the lockfile's two version fields, dependency ranges out of sync, a locked version outside its declared range, packages resolved from anywhere but registry.npmjs.org, missing integrity hashes, `file:`/`git+`/`link:` entries, unreviewed install scripts, and runtime dependencies requiring a newer Node than `engines.node` advertises.
|
|
14
|
+
- **Node 22.x added to the CI test matrix** — `engines` claims `>=18` and 22 is the active LTS.
|
|
15
|
+
- **`.github/dependabot.yml`** — a pinned tree stops receiving upstream fixes on its own, so monthly grouped dependency updates (capped at 3 open PRs) act as the counterweight. GitHub Actions versions are tracked too.
|
|
16
|
+
- **Advisory `npm audit --omit=dev --audit-level=high` step** in the `Code Quality` workflow. Not a required check: a CVE published against a transitive dependency should be visible without blocking unrelated merges.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **CI installs with `npm ci` instead of `npm install`** in both workflows. `npm ci` reproduces the locked tree exactly and aborts if `package.json` and the lockfile have drifted.
|
|
21
|
+
- **ESLint and the JSDoc typecheck are now blocking**, and moved into the `lint` job — one of the three required status checks on `main`. They previously lived in the advisory `Code Quality` workflow, where ESLint additionally ran with `continue-on-error: true`, so neither gate could ever fail a pull request.
|
|
22
|
+
- **Node module caching now works.** `Code Quality` keyed its cache on `hashFiles('**/package-lock.json')` while the lockfile was gitignored, so every run shared one degenerate key. Replaced by `actions/setup-node@v4`'s built-in `cache: 'npm'`.
|
|
23
|
+
- GitHub Actions bumped from `actions/checkout@v3` / `actions/setup-node@v3` / `actions/cache@v3` to v4.
|
|
24
|
+
|
|
25
|
+
### Removed
|
|
26
|
+
|
|
27
|
+
- **`npm install --save-dev eslint prettier` from the `Code Quality` workflow** — it re-resolved both packages to their latest majors on every run (ESLint 9 over the pinned `^8.56.0`) and rewrote `package.json` in the CI workspace, defeating the pinning it ran next to.
|
|
28
|
+
- Redundant CI steps re-running `test-profiles.js`, `test-command-aliases.js` and `test-hooks.js` individually after `npm test` had already run them.
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- `mcp-ssh-manager-setup.md`: the two `.gitignore` templates no longer tell readers to ignore `package-lock.json`.
|
|
33
|
+
|
|
34
|
+
## [3.8.0] - 2026-08-14
|
|
35
|
+
|
|
36
|
+
### Security
|
|
37
|
+
|
|
38
|
+
- **`@modelcontextprotocol/sdk` floor raised to `^1.30.0`** — the declared range (`^1.17.2`) still allowed versions carrying three published advisories, one of them high: cross-client data leak through shared server/transport instance reuse, DNS rebinding protection off by default, and a ReDoS. It also dragged in vulnerable transitive express packages (`body-parser`, `path-to-regexp`, `qs`, `ajv`). `npm audit --omit=dev` now reports **0 vulnerabilities**. Behaviour verified against the real MCP stdio protocol: identical to 1.17.5 (37 tools registered, same negotiation, clean shutdown).
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
|
|
42
|
+
- **Optional `group` field on server config** ([#56](https://github.com/bvisible/mcp-ssh-manager/pull/56) — contributed by [@ice616](https://github.com/ice616), requested in [#55](https://github.com/bvisible/mcp-ssh-manager/issues/55))
|
|
43
|
+
- A free-form label (`SSH_SERVER_<NAME>_GROUP` in `.env`, `group = "..."` in TOML) carried on the server entry itself, so a server's group membership can be read straight off its config when exporting to — or importing from — another tool, with no second file to ship. It round-trips through `exportToToml`/`exportToEnv` and is returned by `ssh_list_servers`.
|
|
44
|
+
- **The label is not just descriptive: it makes the group usable.** `ssh_execute_group` and `ssh_group_manage list` now resolve members from the `group` field as well, so tagging servers is enough to run a command across them — `.server-groups.json` is no longer required to have a working group.
|
|
45
|
+
- Membership is the **union** of both sources: the explicit list stored by `ssh_group_manage` (which keeps carrying strategy, delay and stop-on-error) plus every server tagged with that name. Group names are case-insensitive. Config-derived members are resolved at read time and never written to `.server-groups.json`, so they cannot go stale.
|
|
46
|
+
- A group that exists only through the config is read-only for `ssh_group_manage`; attempting to edit it now returns an error pointing at the server config instead of a bare "not found".
|
|
47
|
+
- The `ssh-manager` add-server wizard asks for an optional group.
|
|
48
|
+
- Tests: new `tests/test-server-groups.js` (14 checks) covers config-derived groups, the union with stored groups, case-insensitivity, read-only enforcement, persistence isolation, the dynamic-group reload regression and group execution; `tests/test-config-field-names.js` gains `group` coverage across the `.env` loader, the TOML loader, the forbidden-field guard and the export round-trip.
|
|
49
|
+
- **Static type-checking over the existing JavaScript** (`npm run typecheck`) — a `tsconfig.json` in `checkJs`/`noEmit` mode runs TypeScript as a linter over JSDoc annotations. **Nothing is compiled and nothing changes for users**: the package still ships plain JS straight from `src/`, with no build step and no `dist/`. Added as a hard gate in the Code Quality workflow.
|
|
50
|
+
- A `ServerConfig` typedef in `src/config-loader.js` documents the resolved server shape and makes its camelCase contract enforceable: reading `serverConfig.default_dir` — the exact issue #49 regression — is now a type error (*"Property 'default_dir' does not exist on type 'ServerConfig'. Did you mean 'defaultDir'?"*) instead of a silent `undefined`. `tests/test-config-field-names.js` keeps guarding the same contract at runtime.
|
|
51
|
+
|
|
52
|
+
### Fixed
|
|
53
|
+
|
|
54
|
+
- **A tunnel on an already-used local port crashed the entire MCP server** — `net.Server#listen` never passes an error to its callback (a failed bind is emitted as an `'error'` event), yet `ssh_tunnel_create` used `listen(port, host, (err) => ...)` and registered no `'error'` listener. On `EADDRINUSE` — the everyday tunnel failure — Node rethrew the unhandled event and killed the process, taking every pooled SSH connection and session with it, while the awaited promise never settled. Binding now rejects properly and the tool returns an error. Guarded by `tests/test-tunnel-listen.js`.
|
|
55
|
+
- **`ssh_sync` always passed an explicit `-p 22` to rsync** — the guard read `serverConfig.port !== '22'`, comparing a number against a string, so it never matched. Harmless in effect, but the intent (omit the flag on the default port) never applied. Found by the new typecheck, along with a matching `parseInt(serverConfig.port || '22')` in `ssh_known_hosts` that only worked because `parseInt` stringifies its argument first.
|
|
56
|
+
- **`ssh_sync` treated native Windows local paths as remote rsync specifications** — a path such as `C:\project` was passed unchanged to MSYS2 rsync, which parsed `C:` as a remote host and attempted an SSH connection to `c`. Windows drive-letter, rooted, UNC, and extended-length paths are now resolved and converted only for the spawned rsync argument while Node keeps the native path for local filesystem checks and logging; relative paths keep their existing semantics with normalized separators. Trailing separators retain rsync's directory-content semantics. A path already written in MSYS2 form (`/c/project`, `//server/share`) — the shape Windows users adopted to work around this very bug — is passed through untouched instead of being mounted twice into `/c/c/project`. Guarded by `tests/test-rsync-path.js` (24 checks: conversion table, pass-through, invariants over every input, platform isolation, failure modes, and a static guard on the `ssh_sync` wiring) plus a real MSYS2 rsync dry run.
|
|
57
|
+
- **The MCP server announced itself as version `1.2.0`** — the `serverInfo` version sent to Claude Code / Codex was a hardcoded literal the release process never bumped, so it had drifted far behind the real package version (3.7.0). It is now derived from `package.json`, the same treatment the CLI banner got in 3.7.0. This matters more under the MCP `2026-07-28` spec, where servers identify themselves in the `_meta` of every result.
|
|
58
|
+
- **`exportToEnv` no longer truncates a `group` containing `#`** — the value is now quoted like `DESCRIPTION`, so a label such as `prod #eu west` survives an export/re-import instead of coming back as `prod`.
|
|
59
|
+
- **The dynamic `all` group now sees TOML-defined servers** — it enumerated `process.env` only, so `ssh_execute_group all` silently skipped every server declared in a TOML config. The group layer now reads the configuration actually loaded by `ConfigLoader`.
|
|
60
|
+
- **The `all` group no longer disappears after the first group edit** — dynamic groups are deliberately never persisted, so every `.server-groups.json` written by `ssh_group_manage` lacked `all`, and the next start loaded that file as the complete set: `ssh_execute_group all` then failed with `Group 'all' not found`. Dynamic groups are now re-injected when the file is read.
|
|
61
|
+
|
|
62
|
+
### Changed
|
|
63
|
+
|
|
64
|
+
- **Dropped the `uuid` dependency** in favour of Node's built-in `crypto.randomUUID()` — available since Node 14.17, and this package already requires Node >= 18. Removes one runtime dependency and the last remaining advisory. Session and tunnel ID formats are unchanged.
|
|
65
|
+
|
|
8
66
|
## [3.7.0] - 2026-07-13
|
|
9
67
|
|
|
10
68
|
### Added
|
|
@@ -420,4 +478,4 @@ None. All existing tools remain fully compatible.
|
|
|
420
478
|
- Interactive server configuration tool
|
|
421
479
|
- Connection testing utility
|
|
422
480
|
- Pre-commit hooks for code quality
|
|
423
|
-
- GitHub Actions workflow for CI/CD
|
|
481
|
+
- GitHub Actions workflow for CI/CD
|
package/CLAUDE.md
CHANGED
|
@@ -69,12 +69,43 @@ See [docs/TOOL_MANAGEMENT.md](docs/TOOL_MANAGEMENT.md) for complete guide.
|
|
|
69
69
|
|
|
70
70
|
### Development and Testing
|
|
71
71
|
```bash
|
|
72
|
+
npm ci # Install the exact tree from package-lock.json
|
|
72
73
|
npm start # Start MCP server (requires stdin)
|
|
74
|
+
npm test # Run the full test suite
|
|
75
|
+
npm run typecheck # Type-check JSDoc with tsc (no build, nothing emitted)
|
|
76
|
+
npm run test:all # Tests + typecheck + validation
|
|
73
77
|
./scripts/validate.sh # Run all validation checks
|
|
74
78
|
node --check src/index.js # Check JavaScript syntax
|
|
75
79
|
python -m py_compile tools/*.py # Check Python syntax
|
|
76
80
|
```
|
|
77
81
|
|
|
82
|
+
**Typecheck**: `tsconfig.json` runs TypeScript in `checkJs`/`noEmit` mode over the plain JS —
|
|
83
|
+
this project ships JavaScript straight from `src/` with no build step, and that must stay true.
|
|
84
|
+
The baseline is 0 errors and CI enforces it, so add JSDoc annotations (or a narrow
|
|
85
|
+
`/** @type {...} */` cast) rather than leaving new errors. `typescript` is pinned to `^6`
|
|
86
|
+
because knip 5 declares `peer typescript ">=5.0.4 <7"` — bumping one requires bumping the other.
|
|
87
|
+
|
|
88
|
+
**Lockfile**: `package-lock.json` is committed and CI installs with `npm ci`, so the tree is
|
|
89
|
+
reproducible and auditable. npm never ships a lockfile inside a published tarball, so this is
|
|
90
|
+
invisible to consumers of the package. Two consequences for maintainers:
|
|
91
|
+
|
|
92
|
+
- **Releases bump three version spots, not one**: `package.json`, `package-lock.json`
|
|
93
|
+
(`.version` *and* `.packages[""].version`) and the README badge. `npm version <x.y.z>` does
|
|
94
|
+
the first two together; a hand edit does not. `npm run test:lockfile` fails when they diverge,
|
|
95
|
+
and so does `npm ci`.
|
|
96
|
+
- **Dependency changes must commit the regenerated lockfile.** After editing `package.json` by
|
|
97
|
+
hand, run `npm install --package-lock-only` and commit both files.
|
|
98
|
+
|
|
99
|
+
`tests/test-lockfile.js` guards the rest: every package resolves to registry.npmjs.org with an
|
|
100
|
+
integrity hash, no `file:`/`git+`/`link:` entries, install scripts limited to a reviewed
|
|
101
|
+
allowlist (`ssh2`, `cpu-features`), and no runtime dependency requiring a newer Node than
|
|
102
|
+
`engines.node` advertises — that last check carries one documented exception,
|
|
103
|
+
`@hono/node-server` (needs Node >=20, pulled by the MCP SDK for its HTTP transport, never
|
|
104
|
+
imported by the stdio server we ship; re-check it when bumping the SDK).
|
|
105
|
+
|
|
106
|
+
**Required status checks on `main`** are `lint`, `test (18.x)` and `test (20.x)`. Renaming those
|
|
107
|
+
jobs or dropping a matrix entry makes `main` unmergeable until branch protection is updated.
|
|
108
|
+
|
|
78
109
|
### Debug Tools (in `debug/` directory)
|
|
79
110
|
```bash
|
|
80
111
|
./debug/test-claude-code.sh # Test Claude Code integration
|
|
@@ -154,6 +185,7 @@ SSH_SERVER_[NAME]_PASSPHRASE=passphrase # Optional, for passphrase-protected
|
|
|
154
185
|
SSH_SERVER_[NAME]_PORT=22 # Optional
|
|
155
186
|
SSH_SERVER_[NAME]_DEFAULT_DIR=/path # Optional default working directory
|
|
156
187
|
SSH_SERVER_[NAME]_SUDO_PASSWORD=pass # Optional for automated sudo
|
|
188
|
+
SSH_SERVER_[NAME]_GROUP=production # Optional, free-form label for grouping/import-export
|
|
157
189
|
SSH_SERVER_[NAME]_PLATFORM=windows # Optional: "linux" (default) or "windows"
|
|
158
190
|
SSH_SERVER_[NAME]_PROXYJUMP=bastion # Optional: name of another server to use as jump host
|
|
159
191
|
SSH_SERVER_[NAME]_PROXYCOMMAND=command # Optional: custom proxy command (ncat, ssh -W, etc.)
|
|
@@ -171,6 +203,7 @@ passphrase = "key_passphrase" # Optional, for passphrase-protected
|
|
|
171
203
|
port = 22 # Optional
|
|
172
204
|
default_dir = "/path" # Optional default working directory
|
|
173
205
|
sudo_password = "pass" # Optional for automated sudo
|
|
206
|
+
group = "production" # Optional, free-form label for grouping/import-export
|
|
174
207
|
platform = "windows" # Optional: "linux" (default) or "windows"
|
|
175
208
|
proxy_jump = "bastion" # Optional: name of another server to use as jump host
|
|
176
209
|
proxy_command = "command" # Optional: custom proxy command (ncat, ssh -W, etc.)
|
|
@@ -191,6 +224,8 @@ forward_agent = true # Optional: forward local ssh-agent t
|
|
|
191
224
|
|
|
192
225
|
6. **Proxy Command Support**: Custom proxy commands (SOCKS5, ssh -W, etc.) are executed locally to establish connections, with proper error handling and timeout management (src/index.js:389-432)
|
|
193
226
|
|
|
227
|
+
7. **Server Groups**: Membership is the union of two sources — the explicit lists in `.server-groups.json` (created via `ssh_group_manage`, which also hold strategy/delay/stopOnError) and the per-server `group` field of the SSH config. Config-derived groups are resolved at read time, never written to `.server-groups.json`, and are read-only for `ssh_group_manage`. `src/index.js` injects the loaded config into the group layer via `setServerConfigProvider()`; without it the module can only see `.env` servers (src/server-groups.js)
|
|
228
|
+
|
|
194
229
|
## Security Considerations
|
|
195
230
|
|
|
196
231
|
- Never commit `.env` files (included in .gitignore)
|
package/CONTRIBUTING.md
CHANGED
|
@@ -36,6 +36,7 @@ Enhancement suggestions are tracked as GitHub issues. When creating an enhanceme
|
|
|
36
36
|
3. Ensure the test suite passes
|
|
37
37
|
4. Make sure your code follows the existing code style
|
|
38
38
|
5. Write a clear commit message
|
|
39
|
+
6. Commit `package-lock.json` if you touched dependencies
|
|
39
40
|
|
|
40
41
|
## Development Process
|
|
41
42
|
|
|
@@ -47,10 +48,21 @@ Enhancement suggestions are tracked as GitHub issues. When creating an enhanceme
|
|
|
47
48
|
|
|
48
49
|
2. Install dependencies:
|
|
49
50
|
```bash
|
|
50
|
-
npm
|
|
51
|
+
npm ci # exact versions from package-lock.json
|
|
51
52
|
pip install -r tools/requirements.txt
|
|
52
53
|
```
|
|
53
54
|
|
|
55
|
+
`package-lock.json` is committed. Use `npm ci` to install: it reproduces the
|
|
56
|
+
exact tree CI uses and fails loudly if the lockfile and `package.json` have
|
|
57
|
+
drifted apart. If you add, remove or bump a dependency, commit the updated
|
|
58
|
+
lockfile alongside `package.json` — `npm run test:lockfile` checks the two
|
|
59
|
+
stay in sync.
|
|
60
|
+
|
|
61
|
+
The lockfile was generated with npm 11. Older npm reformats it (key order,
|
|
62
|
+
the `libc` field) and produces a huge diff even when no version changes —
|
|
63
|
+
if your diff is thousands of lines but `npm run test:lockfile` still passes,
|
|
64
|
+
that is what happened; drop the reformat and keep only real version changes.
|
|
65
|
+
|
|
54
66
|
3. Create a branch:
|
|
55
67
|
```bash
|
|
56
68
|
git checkout -b feature/your-feature-name
|
|
@@ -95,10 +107,14 @@ Enhancement suggestions are tracked as GitHub issues. When creating an enhanceme
|
|
|
95
107
|
|
|
96
108
|
Before submitting a pull request:
|
|
97
109
|
|
|
98
|
-
1.
|
|
99
|
-
2.
|
|
100
|
-
3.
|
|
101
|
-
4.
|
|
110
|
+
1. Run `npm run test:all` (test suite + typecheck + validation script)
|
|
111
|
+
2. Test your changes manually
|
|
112
|
+
3. Ensure existing functionality still works
|
|
113
|
+
4. Test with different server configurations
|
|
114
|
+
5. Verify Claude Code integration works
|
|
115
|
+
|
|
116
|
+
CI installs with `npm ci` on Node 18, 20 and 22, and the `lint` job runs
|
|
117
|
+
ESLint and the JSDoc typecheck as blocking gates.
|
|
102
118
|
|
|
103
119
|
## Documentation
|
|
104
120
|
|
package/README.md
CHANGED
|
@@ -6,12 +6,14 @@ A Model Context Protocol (MCP) server that enables **Claude Code** and **OpenAI
|
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/mcp-ssh-manager)
|
|
8
8
|
[](https://www.npmjs.com/package/mcp-ssh-manager)
|
|
9
|
-
[](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.8.1)
|
|
10
10
|
[](https://claude.ai/code)
|
|
11
11
|
[](https://openai.com/codex)
|
|
12
12
|
[](https://modelcontextprotocol.io)
|
|
13
13
|
[](LICENSE)
|
|
14
14
|
|
|
15
|
+
[](https://mcptoplist.com/server/glama%2Fbvisible%2Fmcp-ssh-manager)
|
|
16
|
+
|
|
15
17
|
</div>
|
|
16
18
|
|
|
17
19
|
<p align="center">
|
|
@@ -20,24 +22,32 @@ A Model Context Protocol (MCP) server that enables **Claude Code** and **OpenAI
|
|
|
20
22
|
|
|
21
23
|
---
|
|
22
24
|
|
|
23
|
-
## 🎉 What's New in v3.
|
|
24
|
-
|
|
25
|
-
**🔗 Per-server SSH agent forwarding (`ForwardAgent`)** (Released: July 13, 2026)
|
|
25
|
+
## 🎉 What's New in v3.8.1
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
- **Safe by construction** — requires a running local agent (`SSH_AUTH_SOCK`); the flag is ignored when no agent is present, so it never breaks a connection. Boolean parsing treats only `true`/`1`/`yes`/`on` as enabled — `FORWARD_AGENT=false` stays off.
|
|
29
|
-
- **⚠️ Defaults to `false`** — agent forwarding lets anyone with root on the remote host use your loaded keys for the life of the connection, so enable it only for servers you trust. See the new *SSH Agent Forwarding* section in the docs.
|
|
27
|
+
**🔒 Reproducible installs: the lockfile is committed, CI installs from it, and a test keeps it honest** (Released: August 28, 2026)
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
- **`package-lock.json` is now committed** ([#60](https://github.com/bvisible/mcp-ssh-manager/pull/60) — contributed by [@cudatuda](https://github.com/cudatuda)) — installs are reproducible, `npm ci` works, and the transitive tree is auditable at last. **Nothing changes if you install from npm**: a lockfile is never shipped inside a published tarball.
|
|
30
|
+
- **🧪 New `npm run test:lockfile` guard** — a lockfile is only worth committing while it stays truthful, so a test locks the ways it rots: version drift, dependency ranges out of sync, a package resolved from anywhere but registry.npmjs.org, a missing integrity hash, a `file:`/`git+`/`link:` entry smuggled into the tree, an install script outside the reviewed allowlist, or a runtime dependency requiring a newer Node than `engines` advertises. Validated by mutating the lockfile 17 different ways — each one caught.
|
|
31
|
+
- **⚙️ CI installs with `npm ci`, and the quality gates finally block.** ESLint and the JSDoc typecheck ran in a workflow that was **not** a required check, ESLint with `continue-on-error` on top — neither could fail a pull request. Both moved into the required `lint` job. Node 22.x added to the test matrix, and the module cache (keyed on a lockfile that did not exist) works now.
|
|
32
|
+
- **🤖 Dependabot** — a pinned tree stops receiving upstream fixes on its own, so monthly grouped updates act as the counterweight.
|
|
34
33
|
|
|
35
|
-
[Read full changelog →](CHANGELOG.md#
|
|
34
|
+
[Read full changelog →](CHANGELOG.md#381---2026-08-28)
|
|
36
35
|
|
|
37
36
|
---
|
|
38
37
|
|
|
39
38
|
## Previous Releases
|
|
40
39
|
|
|
40
|
+
<details>
|
|
41
|
+
<summary><b>📜 Release history — v3.8.0 down to v1.0.0</b> (click to expand)</summary>
|
|
42
|
+
|
|
43
|
+
### v3.8.0 - Groups in your config, `ssh_sync` on Windows, tunnel crash fix (August 14, 2026)
|
|
44
|
+
|
|
45
|
+
- **👥 New optional `group` field per server** ([#56](https://github.com/bvisible/mcp-ssh-manager/pull/56) — contributed by [@ice616](https://github.com/ice616), requested in [#55](https://github.com/bvisible/mcp-ssh-manager/issues/55)) — tag a server with `group = "production"` and it *is* in that group: `ssh_execute_group` resolves members straight from your `.env`/TOML, union'd with any `.server-groups.json` you already keep. Also: `ssh_sync` fixed from a Windows host ([#59](https://github.com/bvisible/mcp-ssh-manager/pull/59) — contributed by [@2836603852](https://github.com/2836603852)), a tunnel on a busy port no longer takes the whole MCP server down, the `@modelcontextprotocol/sdk` floor raised to `^1.30.0` over three advisories, and JSDoc type-checking added to CI. [Full changelog →](CHANGELOG.md#380---2026-08-14)
|
|
46
|
+
|
|
47
|
+
### v3.7.0 - Per-server SSH agent forwarding (July 13, 2026)
|
|
48
|
+
|
|
49
|
+
- **🔗 New opt-in `FORWARD_AGENT` / `forward_agent` option** ([#53](https://github.com/bvisible/mcp-ssh-manager/pull/53) — requested by [@raphaelbahat](https://github.com/raphaelbahat) in [#52](https://github.com/bvisible/mcp-ssh-manager/issues/52)) — the equivalent of OpenSSH's `ForwardAgent yes`, per server: processes on the remote host authenticate to *other* SSH hosts with the keys in your local `ssh-agent`, without copying any private key. Requires a running agent and defaults to `false`. [Full changelog →](CHANGELOG.md#370---2026-07-13)
|
|
50
|
+
|
|
41
51
|
### v3.6.7 - Security: command injection fix in the database helpers (July 11, 2026)
|
|
42
52
|
|
|
43
53
|
- **🔒 Every `ssh_db_*` argument is now shell-quoted** ([#51](https://github.com/bvisible/mcp-ssh-manager/pull/51) — responsibly disclosed by **Ugur Ozer, Aeon AI Risk Management** (http://airiskmanagement.ca), see [#48](https://github.com/bvisible/mcp-ssh-manager/issues/48)) — caller-controlled values (`ssh_db_list` most notably, which stayed allowed in `readonly`/`restricted` modes) were interpolated into shell-evaluated strings, allowing arbitrary command execution on the SSH target. A centralized `shellQuote()` now wraps every value across all 15 builders, guarded by a 648-combination injection test. [Full changelog →](CHANGELOG.md#367---2026-07-11)
|
|
@@ -178,6 +188,8 @@ This release adds **12 new MCP tools** transforming SSH Manager into a comprehen
|
|
|
178
188
|
|
|
179
189
|
[Read Full Changelog →](CHANGELOG.md#300---2025-10-01)
|
|
180
190
|
|
|
191
|
+
</details>
|
|
192
|
+
|
|
181
193
|
---
|
|
182
194
|
|
|
183
195
|
## 📑 Table of Contents
|
|
@@ -447,6 +459,7 @@ key_path = "~/.ssh/id_rsa" # for SSH key auth (recommended)
|
|
|
447
459
|
passphrase = "key_passphrase" # optional, for passphrase-protected keys
|
|
448
460
|
port = 22
|
|
449
461
|
default_dir = "/var/www"
|
|
462
|
+
group = "production" # optional, free-form label for grouping/import-export
|
|
450
463
|
description = "Production server"
|
|
451
464
|
|
|
452
465
|
[ssh_servers.staging]
|
|
@@ -676,6 +689,7 @@ SSH_SERVER_[NAME]_PASSPHRASE=key_passphrase # Optional, for passphrase-protecte
|
|
|
676
689
|
SSH_SERVER_[NAME]_PORT=22 # Optional, defaults to 22
|
|
677
690
|
SSH_SERVER_[NAME]_DEFAULT_DIR=/path/to/dir # Optional, default working directory
|
|
678
691
|
SSH_SERVER_[NAME]_DESCRIPTION=Description # Optional
|
|
692
|
+
SSH_SERVER_[NAME]_GROUP=production # Optional, free-form label for grouping/import-export
|
|
679
693
|
SSH_SERVER_[NAME]_PLATFORM=windows # Optional: "linux" (default) or "windows"
|
|
680
694
|
SSH_SERVER_[NAME]_PROXYJUMP=bastion # Optional: name of another server to use as jump host
|
|
681
695
|
SSH_SERVER_[NAME]_PROXYCOMMAND=command # Optional: custom proxy command (ncat, ssh -W, etc.)
|
|
@@ -893,6 +907,41 @@ proxy_command = "C:\\Windows\\System32\\OpenSSH\\ssh.exe -W %h:%p user@jump-host
|
|
|
893
907
|
|
|
894
908
|
The proxy command must be a valid command that reads from stdin and writes to stdout, accepting `%h` and `%p` placeholders for host and port.
|
|
895
909
|
|
|
910
|
+
### Server Groups
|
|
911
|
+
|
|
912
|
+
Tag a server with `group` and it becomes part of that group — no extra file to maintain. The label is free-form and travels with the server definition, so it survives an export to (or import from) another tool.
|
|
913
|
+
|
|
914
|
+
```env
|
|
915
|
+
SSH_SERVER_WEB1_HOST=10.0.0.1
|
|
916
|
+
SSH_SERVER_WEB1_USER=deploy
|
|
917
|
+
SSH_SERVER_WEB1_GROUP=production
|
|
918
|
+
|
|
919
|
+
SSH_SERVER_WEB2_HOST=10.0.0.2
|
|
920
|
+
SSH_SERVER_WEB2_USER=deploy
|
|
921
|
+
SSH_SERVER_WEB2_GROUP=production
|
|
922
|
+
```
|
|
923
|
+
|
|
924
|
+
Or in TOML:
|
|
925
|
+
```toml
|
|
926
|
+
[ssh_servers.web1]
|
|
927
|
+
host = "10.0.0.1"
|
|
928
|
+
user = "deploy"
|
|
929
|
+
group = "production"
|
|
930
|
+
```
|
|
931
|
+
|
|
932
|
+
Both servers are then reachable as a group:
|
|
933
|
+
|
|
934
|
+
```
|
|
935
|
+
Run "uptime" on the production group → ssh_execute_group
|
|
936
|
+
List my server groups → ssh_group_manage (action: list)
|
|
937
|
+
```
|
|
938
|
+
|
|
939
|
+
`ssh_list_servers` also reports the group of each server, so you can see membership without opening the config.
|
|
940
|
+
|
|
941
|
+
**How it combines with `ssh_group_manage`:** groups you create with `ssh_group_manage` live in `.server-groups.json` and carry execution settings (strategy, delay, stop-on-error). Groups implied by the `group` field carry membership only. When a name exists on both sides, **membership is the union** — the stored list plus every server tagged with that name — and the stored execution settings apply. Group names are case-insensitive.
|
|
942
|
+
|
|
943
|
+
A group that exists only through the `group` field is read-only for `ssh_group_manage`: to change who belongs to it, edit the servers' `group` in your `.env`/TOML. Creating a group of the same name with `ssh_group_manage` is still allowed and simply adds stored members and settings on top.
|
|
944
|
+
|
|
896
945
|
### Documentation
|
|
897
946
|
- [DEPLOYMENT_GUIDE.md](docs/DEPLOYMENT_GUIDE.md) - Deployment strategies and permission handling
|
|
898
947
|
- [ALIASES_AND_HOOKS.md](docs/ALIASES_AND_HOOKS.md) - Command aliases and automation hooks
|
|
@@ -1061,6 +1110,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
1061
1110
|
### SSH Sync (rsync)
|
|
1062
1111
|
- Password authentication requires `sshpass` to be installed
|
|
1063
1112
|
- SSH key authentication is recommended for better security and reliability
|
|
1113
|
+
- **Windows MCP hosts**: pass native local paths such as `local:C:\project` or `local:.\project`; `ssh_sync` converts drive-letter and UNC paths to MSYS2 format before launching rsync. Prefer native paths, since Node checks them on disk using Windows path semantics — a path already written as `/c/...` or `//server/share` is passed through to rsync untouched rather than converted twice.
|
|
1064
1114
|
- Large file transfers may take time and appear to hang - be patient
|
|
1065
1115
|
|
|
1066
1116
|
### Connection Management
|
package/cli/install.sh
CHANGED
|
@@ -69,6 +69,12 @@ echo "Copying CLI files to $CLI_HOME..."
|
|
|
69
69
|
rm -rf "$CLI_HOME"
|
|
70
70
|
cp -r "$SCRIPT_DIR" "$CLI_HOME"
|
|
71
71
|
|
|
72
|
+
# Bundle package.json next to the CLI so it can report the real build version
|
|
73
|
+
# (the CLI derives its version from package.json instead of a hardcoded string).
|
|
74
|
+
if [ -f "$SCRIPT_DIR/../package.json" ]; then
|
|
75
|
+
cp "$SCRIPT_DIR/../package.json" "$CLI_HOME/package.json"
|
|
76
|
+
fi
|
|
77
|
+
|
|
72
78
|
# Create executable symlink
|
|
73
79
|
$SUDO ln -sf "$CLI_HOME/ssh-manager" "$INSTALL_DIR/ssh-manager"
|
|
74
80
|
|
package/cli/lib/menu.sh
CHANGED
|
@@ -177,7 +177,24 @@ wizard_add_server() {
|
|
|
177
177
|
echo "Set a default directory for this server (optional)."
|
|
178
178
|
echo "Example: /var/www/html, /home/user/app, /opt/services"
|
|
179
179
|
prompt_input "Default directory" "" "default_dir"
|
|
180
|
-
|
|
180
|
+
|
|
181
|
+
local group
|
|
182
|
+
echo
|
|
183
|
+
echo "Assign this server to a group (optional)."
|
|
184
|
+
echo "Servers sharing a group can be targeted together with ssh_execute_group."
|
|
185
|
+
echo "Example: production, staging, customer-acme"
|
|
186
|
+
prompt_input "Group" "" "group"
|
|
187
|
+
|
|
188
|
+
local forward_agent="n"
|
|
189
|
+
echo
|
|
190
|
+
echo "Forward your local ssh-agent to this server (optional)."
|
|
191
|
+
echo "Lets remote processes use your local keys — e.g. git over SSH."
|
|
192
|
+
print_warning "Security: anyone with root on this host can use your loaded keys"
|
|
193
|
+
print_warning "for the life of the connection. Only enable for servers you trust."
|
|
194
|
+
if prompt_yes_no "Enable SSH agent forwarding?" "n"; then
|
|
195
|
+
forward_agent="y"
|
|
196
|
+
fi
|
|
197
|
+
|
|
181
198
|
# Step 5: Review
|
|
182
199
|
echo
|
|
183
200
|
print_subheader "Step 5: Review Configuration"
|
|
@@ -198,18 +215,35 @@ wizard_add_server() {
|
|
|
198
215
|
if [ -n "$default_dir" ]; then
|
|
199
216
|
print_table_row "Default Dir:" "$default_dir"
|
|
200
217
|
fi
|
|
201
|
-
|
|
218
|
+
if [ -n "$group" ]; then
|
|
219
|
+
print_table_row "Group:" "$group"
|
|
220
|
+
fi
|
|
221
|
+
if [ "$forward_agent" = "y" ]; then
|
|
222
|
+
print_table_row "Agent Forwarding:" "enabled"
|
|
223
|
+
fi
|
|
224
|
+
|
|
202
225
|
echo
|
|
203
226
|
if prompt_yes_no "Save this configuration?" "y"; then
|
|
204
227
|
# Save to .env
|
|
205
228
|
add_server_to_env "$server_name" "$host" "$user" "$auth_type" "$auth_value" "$port" "$description"
|
|
206
|
-
|
|
229
|
+
|
|
230
|
+
local name_upper="$(echo "$server_name" | tr '[:lower:]' '[:upper:]')"
|
|
231
|
+
|
|
207
232
|
# Add default directory if specified
|
|
208
233
|
if [ -n "$default_dir" ]; then
|
|
209
|
-
local name_upper="$(echo "$server_name" | tr '[:lower:]' '[:upper:]')"
|
|
210
234
|
echo "SSH_SERVER_${name_upper}_DEFAULT_DIR=$default_dir" >> "$SSH_MANAGER_ENV"
|
|
211
235
|
fi
|
|
212
|
-
|
|
236
|
+
|
|
237
|
+
# Add group if specified (quoted: free-form text, may contain spaces)
|
|
238
|
+
if [ -n "$group" ]; then
|
|
239
|
+
echo "SSH_SERVER_${name_upper}_GROUP=\"$group\"" >> "$SSH_MANAGER_ENV"
|
|
240
|
+
fi
|
|
241
|
+
|
|
242
|
+
# Enable agent forwarding if opted in
|
|
243
|
+
if [ "$forward_agent" = "y" ]; then
|
|
244
|
+
echo "SSH_SERVER_${name_upper}_FORWARD_AGENT=true" >> "$SSH_MANAGER_ENV"
|
|
245
|
+
fi
|
|
246
|
+
|
|
213
247
|
echo
|
|
214
248
|
print_success "Server '$server_name' added successfully!"
|
|
215
249
|
|
package/cli/ssh-manager
CHANGED
|
@@ -21,8 +21,24 @@ source "$SCRIPT_DIR/lib/menu.sh"
|
|
|
21
21
|
source "$SCRIPT_DIR/commands/server.sh"
|
|
22
22
|
source "$SCRIPT_DIR/commands/tools.sh"
|
|
23
23
|
|
|
24
|
-
# Version
|
|
25
|
-
|
|
24
|
+
# Version — derived from package.json so it always reflects the real build,
|
|
25
|
+
# never a hardcoded literal that drifts across releases. Works both in-repo
|
|
26
|
+
# (cli/../package.json) and from an installed copy (package.json bundled next
|
|
27
|
+
# to this script by install.sh). Uses sed only, so no jq dependency.
|
|
28
|
+
get_cli_version() {
|
|
29
|
+
local pkg ver
|
|
30
|
+
for pkg in "$SCRIPT_DIR/../package.json" "$SCRIPT_DIR/package.json"; do
|
|
31
|
+
if [ -f "$pkg" ]; then
|
|
32
|
+
ver="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$pkg" | head -n1)"
|
|
33
|
+
if [ -n "$ver" ]; then
|
|
34
|
+
echo "$ver"
|
|
35
|
+
return
|
|
36
|
+
fi
|
|
37
|
+
fi
|
|
38
|
+
done
|
|
39
|
+
echo "unknown"
|
|
40
|
+
}
|
|
41
|
+
VERSION="$(get_cli_version)"
|
|
26
42
|
|
|
27
43
|
# Show version
|
|
28
44
|
show_version() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-ssh-manager",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.1",
|
|
4
4
|
"description": "MCP SSH Manager: Model Context Protocol server for SSH remote server management. Control SSH connections from Claude Code and OpenAI Codex - execute commands, transfer files, database operations, backups, health monitoring, and DevOps automation. NEW: Tool activation system reduces context usage by 92%",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"setup": "npm install && pip install -r tools/requirements.txt",
|
|
14
14
|
"configure": "python tools/server-manager.py",
|
|
15
15
|
"test-connection": "python tools/test-connection.py",
|
|
16
|
-
"test": "npm run test:profiles && npm run test:aliases && npm run test:hooks && npm run test:tools && npm run test:policy && npm run test:ping && npm run test:config && npm run test:fieldnames && npm run test:agentforward && npm run test:lifecycle && npm run test:sync && npm run test:dbquoting && npm run test:dbinjection && npm run test:dbrowcount",
|
|
16
|
+
"test": "npm run test:lockfile && npm run test:profiles && npm run test:aliases && npm run test:hooks && npm run test:tools && npm run test:policy && npm run test:ping && npm run test:config && npm run test:fieldnames && npm run test:groups && npm run test:agentforward && npm run test:lifecycle && npm run test:tunnel && npm run test:sync && npm run test:sync-path && npm run test:dbquoting && npm run test:dbinjection && npm run test:dbrowcount",
|
|
17
|
+
"test:lockfile": "node tests/test-lockfile.js",
|
|
17
18
|
"test:profiles": "node tests/test-profiles.js",
|
|
18
19
|
"test:aliases": "node tests/test-command-aliases.js",
|
|
19
20
|
"test:hooks": "node tests/test-hooks.js",
|
|
@@ -22,14 +23,18 @@
|
|
|
22
23
|
"test:ping": "node tests/test-ssh-ping.js",
|
|
23
24
|
"test:config": "node tests/test-server-config-manager.js",
|
|
24
25
|
"test:fieldnames": "node tests/test-config-field-names.js",
|
|
26
|
+
"test:groups": "node tests/test-server-groups.js",
|
|
25
27
|
"test:agentforward": "node tests/test-agent-forward.js",
|
|
26
28
|
"test:lifecycle": "node tests/test-lifecycle.js",
|
|
29
|
+
"test:tunnel": "node tests/test-tunnel-listen.js",
|
|
27
30
|
"test:sync": "node tests/test-sync-stats.js",
|
|
31
|
+
"test:sync-path": "node tests/test-rsync-path.js",
|
|
28
32
|
"test:dbquoting": "node tests/test-database-query-quoting.js",
|
|
29
33
|
"test:dbinjection": "node tests/test-database-injection.js",
|
|
30
34
|
"test:dbrowcount": "node tests/test-database-row-count.js",
|
|
31
|
-
"test:all": "npm test && ./scripts/validate.sh",
|
|
35
|
+
"test:all": "npm test && npm run typecheck && ./scripts/validate.sh",
|
|
32
36
|
"validate": "./scripts/validate.sh",
|
|
37
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
33
38
|
"lint": "eslint src/*.js",
|
|
34
39
|
"format": "prettier --write 'src/**/*.js' 'tests/**/*.js'"
|
|
35
40
|
},
|
|
@@ -84,16 +89,16 @@
|
|
|
84
89
|
"homepage": "https://github.com/bvisible/mcp-ssh-manager#readme",
|
|
85
90
|
"dependencies": {
|
|
86
91
|
"@iarna/toml": "^2.2.5",
|
|
87
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
92
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
88
93
|
"dotenv": "^16.4.5",
|
|
89
94
|
"ssh2": "^1.17.0",
|
|
90
|
-
"uuid": "^11.1.0",
|
|
91
95
|
"zod": "^3.25.76"
|
|
92
96
|
},
|
|
93
97
|
"devDependencies": {
|
|
94
98
|
"eslint": "^8.56.0",
|
|
95
99
|
"knip": "^5.0.0",
|
|
96
|
-
"prettier": "^3.2.4"
|
|
100
|
+
"prettier": "^3.2.4",
|
|
101
|
+
"typescript": "^6.0.3"
|
|
97
102
|
},
|
|
98
103
|
"engines": {
|
|
99
104
|
"node": ">=18.0.0"
|
package/src/backup-manager.js
CHANGED
|
@@ -419,7 +419,7 @@ export function parseBackupsList(output) {
|
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
// Sort by created_at descending
|
|
422
|
-
return backups.sort((a, b) => new Date(b.created_at) - new Date(a.created_at));
|
|
422
|
+
return backups.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
|
|
423
423
|
}
|
|
424
424
|
|
|
425
425
|
/**
|
package/src/config-loader.js
CHANGED
|
@@ -6,6 +6,40 @@ import os from 'os';
|
|
|
6
6
|
import { logger } from './logger.js';
|
|
7
7
|
import { VALID_MODES } from './policy.js';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* A resolved SSH server configuration, as produced by this loader and consumed
|
|
11
|
+
* by every handler. **Field names are camelCase, always** — the `.env` keys
|
|
12
|
+
* (`SUDO_PASSWORD`) and TOML keys (`sudo_password`) are source syntax and are
|
|
13
|
+
* mapped here; they never survive into a resolved config.
|
|
14
|
+
*
|
|
15
|
+
* This is the contract that broke in issue #49: handlers kept reading the
|
|
16
|
+
* pre-v3.0.0 snake_case names, which silently evaluated to `undefined`. Anything
|
|
17
|
+
* typed as a `ServerConfig` now makes that a type error rather than a runtime
|
|
18
|
+
* no-op. `tests/test-config-field-names.js` guards the same contract at runtime.
|
|
19
|
+
*
|
|
20
|
+
* @typedef {Object} ServerConfig
|
|
21
|
+
* @property {string} name Normalized (lowercased) server name.
|
|
22
|
+
* @property {string} host Hostname or IP address.
|
|
23
|
+
* @property {string} [user] SSH user.
|
|
24
|
+
* @property {string} [password] Password for password authentication.
|
|
25
|
+
* @property {string} [keyPath] Path to the private key (`KEYPATH` / `key_path`).
|
|
26
|
+
* @property {string} [passphrase] Passphrase for a protected private key.
|
|
27
|
+
* @property {number} [port] TCP port; defaults to 22.
|
|
28
|
+
* @property {string} [defaultDir] Working directory used when a tool omits `cwd`.
|
|
29
|
+
* @property {string} [sudoPassword] Password piped to `sudo -S`.
|
|
30
|
+
* @property {string} [description] Free-form description.
|
|
31
|
+
* @property {string} [group] Free-form group label; also feeds server groups.
|
|
32
|
+
* @property {string} [platform] `'linux'` (default) or `'windows'`.
|
|
33
|
+
* @property {string} [proxyJump] Name of another configured server to jump through.
|
|
34
|
+
* @property {string} [proxyCommand] Custom proxy command (`%h` / `%p` placeholders).
|
|
35
|
+
* @property {boolean} [forwardAgent] Forward the local ssh-agent to this server.
|
|
36
|
+
* @property {string} [mode] Security mode: `unrestricted`, `readonly` or `restricted`.
|
|
37
|
+
* @property {string[]} [allowPatterns] Regex sources allowed in `restricted` mode.
|
|
38
|
+
* @property {string[]} [denyPatterns] Regex sources always refused.
|
|
39
|
+
* @property {string} [auditLog] Path to a per-server audit log.
|
|
40
|
+
* @property {'env'|'toml'} [source] Which configuration source won for this server.
|
|
41
|
+
*/
|
|
42
|
+
|
|
9
43
|
// Parse a `;`-separated list of regex pattern strings. Empty entries are dropped.
|
|
10
44
|
// We do NOT compile here — that happens lazily in policy.js so config-loader stays
|
|
11
45
|
// free of regex error handling.
|
|
@@ -44,7 +78,9 @@ function parseBool(raw) {
|
|
|
44
78
|
|
|
45
79
|
export class ConfigLoader {
|
|
46
80
|
constructor() {
|
|
81
|
+
/** @type {Map<string, ServerConfig>} */
|
|
47
82
|
this.servers = new Map();
|
|
83
|
+
/** @type {string|null} */
|
|
48
84
|
this.configSource = null;
|
|
49
85
|
}
|
|
50
86
|
|
|
@@ -53,6 +89,8 @@ export class ConfigLoader {
|
|
|
53
89
|
* 1. Environment variables (highest priority)
|
|
54
90
|
* 2. .env file
|
|
55
91
|
* 3. TOML config file (lowest priority)
|
|
92
|
+
*
|
|
93
|
+
* @returns {Promise<Map<string, ServerConfig>>}
|
|
56
94
|
*/
|
|
57
95
|
async load(options = {}) {
|
|
58
96
|
const {
|
|
@@ -145,6 +183,7 @@ export class ConfigLoader {
|
|
|
145
183
|
defaultDir: serverConfig.default_dir || serverConfig.default_directory || serverConfig.cwd,
|
|
146
184
|
sudoPassword: serverConfig.sudo_password,
|
|
147
185
|
description: serverConfig.description,
|
|
186
|
+
group: serverConfig.group,
|
|
148
187
|
platform: serverConfig.platform ? serverConfig.platform.toLowerCase() : undefined,
|
|
149
188
|
proxyJump: serverConfig.proxy_jump,
|
|
150
189
|
proxyCommand: serverConfig.proxy_command || serverConfig.proxycommand,
|
|
@@ -205,6 +244,7 @@ export class ConfigLoader {
|
|
|
205
244
|
);
|
|
206
245
|
}
|
|
207
246
|
|
|
247
|
+
/** @type {ServerConfig} */
|
|
208
248
|
const server = {
|
|
209
249
|
name: serverName,
|
|
210
250
|
host: value,
|
|
@@ -216,6 +256,7 @@ export class ConfigLoader {
|
|
|
216
256
|
defaultDir: env[`SSH_SERVER_${match[1]}_DEFAULT_DIR`],
|
|
217
257
|
sudoPassword: env[`SSH_SERVER_${match[1]}_SUDO_PASSWORD`],
|
|
218
258
|
description: env[`SSH_SERVER_${match[1]}_DESCRIPTION`],
|
|
259
|
+
group: env[`SSH_SERVER_${match[1]}_GROUP`],
|
|
219
260
|
platform: (env[`SSH_SERVER_${match[1]}_PLATFORM`] || '').toLowerCase() || undefined,
|
|
220
261
|
proxyJump: env[`SSH_SERVER_${match[1]}_PROXYJUMP`],
|
|
221
262
|
proxyCommand: env[`SSH_SERVER_${match[1]}_PROXYCOMMAND`],
|
|
@@ -235,6 +276,9 @@ export class ConfigLoader {
|
|
|
235
276
|
|
|
236
277
|
/**
|
|
237
278
|
* Get server configuration by name
|
|
279
|
+
*
|
|
280
|
+
* @param {string} name
|
|
281
|
+
* @returns {ServerConfig|undefined}
|
|
238
282
|
*/
|
|
239
283
|
getServer(name) {
|
|
240
284
|
return this.servers.get(name.toLowerCase());
|
|
@@ -242,6 +286,8 @@ export class ConfigLoader {
|
|
|
242
286
|
|
|
243
287
|
/**
|
|
244
288
|
* Get all server configurations
|
|
289
|
+
*
|
|
290
|
+
* @returns {ServerConfig[]}
|
|
245
291
|
*/
|
|
246
292
|
getAllServers() {
|
|
247
293
|
return Array.from(this.servers.values());
|
|
@@ -275,6 +321,7 @@ export class ConfigLoader {
|
|
|
275
321
|
if (server.defaultDir) serverConfig.default_dir = server.defaultDir;
|
|
276
322
|
if (server.sudoPassword) serverConfig.sudo_password = server.sudoPassword;
|
|
277
323
|
if (server.description) serverConfig.description = server.description;
|
|
324
|
+
if (server.group) serverConfig.group = server.group;
|
|
278
325
|
if (server.platform) serverConfig.platform = server.platform;
|
|
279
326
|
if (server.proxyJump) serverConfig.proxy_jump = server.proxyJump;
|
|
280
327
|
if (server.proxyCommand) serverConfig.proxy_command = server.proxyCommand;
|
|
@@ -317,6 +364,9 @@ export class ConfigLoader {
|
|
|
317
364
|
if (server.defaultDir) lines.push(`SSH_SERVER_${upperName}_DEFAULT_DIR=${server.defaultDir}`);
|
|
318
365
|
if (server.sudoPassword) lines.push(`SSH_SERVER_${upperName}_SUDO_PASSWORD="${server.sudoPassword}"`);
|
|
319
366
|
if (server.description) lines.push(`SSH_SERVER_${upperName}_DESCRIPTION="${server.description}"`);
|
|
367
|
+
// Quoted like DESCRIPTION: free-form text, so an unquoted value would be
|
|
368
|
+
// truncated at the first ` #` when the generated file is read back.
|
|
369
|
+
if (server.group) lines.push(`SSH_SERVER_${upperName}_GROUP="${server.group}"`);
|
|
320
370
|
if (server.platform) lines.push(`SSH_SERVER_${upperName}_PLATFORM=${server.platform}`);
|
|
321
371
|
if (server.proxyJump) lines.push(`SSH_SERVER_${upperName}_PROXYJUMP=${server.proxyJump}`);
|
|
322
372
|
if (server.proxyCommand) lines.push(`SSH_SERVER_${upperName}_PROXYCOMMAND=${server.proxyCommand}`);
|
|
@@ -342,6 +392,7 @@ export class ConfigLoader {
|
|
|
342
392
|
* Save configuration to Codex TOML format
|
|
343
393
|
*/
|
|
344
394
|
async saveToCodexConfig(codexConfigPath = path.join(os.homedir(), '.codex', 'config.toml')) {
|
|
395
|
+
/** @type {Record<string, any>} */
|
|
345
396
|
let config = {};
|
|
346
397
|
|
|
347
398
|
// Load existing config if it exists
|