mcp-ssh-manager 3.8.1 → 3.8.2

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
@@ -5,6 +5,23 @@ 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.2] - 2026-08-28
9
+
10
+ ### Security
11
+
12
+ - **The sudo password no longer reaches the remote command line** ([#34](https://github.com/bvisible/mcp-ssh-manager/issues/34)). `ssh_execute_sudo` and the three privileged steps of `ssh_deploy` built `echo "<password>" | sudo -S <cmd>`, which published the password to the remote process list, `/proc/<pid>/cmdline` and any `auditd` trail for the lifetime of the `echo` — readable by every account on the host. The existing output masking never helped: it only redacted the copy sent back to the agent. The password now travels on the SSH exec channel's stdin (`sudo -S -k -p ''`), where no other process can observe it. `-k` is required: without it an already-authorised sudo skips the prompt, leaving the password in the pipe for the command itself to read as input. Guarded by `npm run test:sudostdin`, which also fails if the old pipeline reappears anywhere in `src/`.
13
+
14
+ ### Added
15
+
16
+ - **`server.json`** — the manifest for the official [MCP Registry](https://registry.modelcontextprotocol.io), published as `io.github.bvisible/mcp-ssh-manager`, plus the `mcpName` field in `package.json` that proves package ownership. The registry is what feeds MCP clients today; the project was absent from it.
17
+ - **OpenSSF Scorecard workflow and badge** — a public grade of the repository's supply-chain posture. For a server that hands an agent a shell on production machines, that grade is part of the product.
18
+ - **`Release` workflow** publishing to npm with build provenance and attaching a CycloneDX SBOM to each GitHub release. Removes the hand-publish step that failed twice on 2026-08-28 (expired token, then a 2FA prompt), and lets anyone verify the tarball's origin with `npm audit signatures`.
19
+ - **README section "Giving an agent SSH access, safely"** documenting the per-server `unrestricted` / `readonly` / `restricted` modes, which existed since v3.5.0 but were never surfaced where readers land.
20
+
21
+ ### Fixed
22
+
23
+ - `SSHManager.execCommand` accepts an `stdin` option, written to the exec channel and then closed. Commands that pass no stdin are untouched, so interactive remote processes keep working.
24
+
8
25
  ## [3.8.1] - 2026-08-28
9
26
 
10
27
  ### Added
package/README.md CHANGED
@@ -6,10 +6,11 @@ A Model Context Protocol (MCP) server that enables **Claude Code** and **OpenAI
6
6
 
7
7
  [![npm version](https://img.shields.io/npm/v/mcp-ssh-manager.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/mcp-ssh-manager)
8
8
  [![npm downloads](https://img.shields.io/npm/dt/mcp-ssh-manager.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/mcp-ssh-manager)
9
- [![Version](https://img.shields.io/badge/Version-3.8.1-brightgreen?style=for-the-badge)](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.8.1)
9
+ [![Version](https://img.shields.io/badge/Version-3.8.2-brightgreen?style=for-the-badge)](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.8.2)
10
10
  [![Claude Code](https://img.shields.io/badge/Claude_Code-Compatible-5A67D8?style=for-the-badge&logo=anthropic)](https://claude.ai/code)
11
11
  [![OpenAI Codex](https://img.shields.io/badge/OpenAI_Codex-Compatible-00A67E?style=for-the-badge&logo=openai)](https://openai.com/codex)
12
12
  [![MCP](https://img.shields.io/badge/MCP-Server-orange?style=for-the-badge)](https://modelcontextprotocol.io)
13
+ [![OpenSSF Scorecard](https://img.shields.io/ossf-scorecard/github.com/bvisible/mcp-ssh-manager?style=for-the-badge&label=OpenSSF)](https://scorecard.dev/viewer/?uri=github.com/bvisible/mcp-ssh-manager)
13
14
  [![License](https://img.shields.io/badge/License-MIT-blue?style=for-the-badge)](LICENSE)
14
15
 
15
16
  [![MCP Toplist](https://mcptoplist.com/badge/glama%2Fbvisible%2Fmcp-ssh-manager.svg)](https://mcptoplist.com/server/glama%2Fbvisible%2Fmcp-ssh-manager)
@@ -22,23 +23,63 @@ A Model Context Protocol (MCP) server that enables **Claude Code** and **OpenAI
22
23
 
23
24
  ---
24
25
 
25
- ## 🎉 What's New in v3.8.1
26
+ ## 🎉 What's New in v3.8.2
26
27
 
27
- **🔒 Reproducible installs: the lockfile is committed, CI installs from it, and a test keeps it honest** (Released: August 28, 2026)
28
+ **🔐 The sudo password stops leaking to the remote process list, and the server joins the official MCP Registry** (Released: August 28, 2026)
28
29
 
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.
30
+ - **🔒 Security fix: the sudo password no longer reaches the remote command line** ([#34](https://github.com/bvisible/mcp-ssh-manager/issues/34)) — `ssh_execute_sudo` and `ssh_deploy` built `echo "<password>" | sudo -S …`, leaving the password visible in `ps` and `/proc/<pid>/cmdline` to every account on the host. It now travels on the SSH channel's stdin, where nothing else can read it. A regression test fails if the old pattern comes back anywhere in `src/`.
31
+ - **📖 Listed in the official MCP Registry** as `io.github.bvisible/mcp-ssh-manager` — the registry that feeds MCP clients. The project was simply absent from it.
32
+ - **🛡️ OpenSSF Scorecard + signed provenance + SBOM** — releases now publish from CI with build provenance you can check via `npm audit signatures`, and each one carries a CycloneDX SBOM.
33
+ - **📋 The security modes are finally documented where people land** — `readonly` and `restricted` have existed since v3.5.0 and were buried. See the section right below.
33
34
 
34
- [Read full changelog →](CHANGELOG.md#381---2026-08-28)
35
+ [Read full changelog →](CHANGELOG.md#382---2026-08-28)
36
+
37
+ ---
38
+
39
+ ## 🔐 Giving an agent SSH access, safely
40
+
41
+ An MCP SSH server is the most dangerous tool you can hand an AI agent: a shell on
42
+ machines that matter. This one is built so you decide how far the agent can go —
43
+ **per server**, not globally.
44
+
45
+ | Mode | What the agent can do |
46
+ |---|---|
47
+ | `unrestricted` *(default)* | Everything. Same behaviour as any other SSH MCP server. |
48
+ | `readonly` | Mutating tools are refused outright — no deploy, no upload, no sudo, no database import. Read commands still work. |
49
+ | `restricted` | Every command must match an allow pattern **and** no deny pattern. Anything else is refused before it reaches the host. |
50
+
51
+ ```env
52
+ SSH_SERVER_PROD_MODE=readonly
53
+ SSH_SERVER_STAGING_MODE=restricted
54
+ SSH_SERVER_STAGING_ALLOW_PATTERNS=^systemctl (status|restart) myapp$;^tail -n \d+ /var/log/
55
+ ```
56
+
57
+ Alongside that:
58
+
59
+ - **The sudo password never reaches the remote command line.** It travels on the
60
+ SSH channel's stdin, so it is not visible in `ps`, in `/proc/<pid>/cmdline`, or
61
+ in an `auditd` trail — unlike the `echo "$pass" | sudo -S` pattern common in
62
+ this category ([#34](https://github.com/bvisible/mcp-ssh-manager/issues/34)).
63
+ - **Every database argument is shell-quoted** through one centralised helper,
64
+ guarded by a 648-combination injection test.
65
+ - **Read-only SQL is enforced**, not suggested: `ssh_db_query` refuses anything
66
+ that is not a `SELECT`.
67
+ - **Vulnerabilities are published, not buried.** See [SECURITY.md](SECURITY.md)
68
+ for the reporting process and the advisories already fixed.
69
+ - **Reproducible installs**: the lockfile is committed, CI installs with
70
+ `npm ci`, and a test enforces that every dependency resolves to
71
+ registry.npmjs.org with an integrity hash and no unreviewed install scripts.
35
72
 
36
73
  ---
37
74
 
38
75
  ## Previous Releases
39
76
 
40
77
  <details>
41
- <summary><b>📜 Release history — v3.8.0 down to v1.0.0</b> (click to expand)</summary>
78
+ <summary><b>📜 Release history — v3.8.1 down to v1.0.0</b> (click to expand)</summary>
79
+
80
+ ### v3.8.1 - Reproducible installs and blocking quality gates (August 28, 2026)
81
+
82
+ - **Committed lockfile** ([#60](https://github.com/bvisible/mcp-ssh-manager/pull/60) — contributed by [@cudatuda](https://github.com/cudatuda)) plus `npm run test:lockfile` guarding it against drift and tampering. CI installs with `npm ci`; ESLint and the JSDoc typecheck became blocking gates after being purely decorative. [Full changelog →](CHANGELOG.md#381---2026-08-28)
42
83
 
43
84
  ### v3.8.0 - Groups in your config, `ssh_sync` on Windows, tunnel crash fix (August 14, 2026)
44
85
 
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "mcp-ssh-manager",
3
- "version": "3.8.1",
3
+ "version": "3.8.2",
4
+ "mcpName": "io.github.bvisible/mcp-ssh-manager",
4
5
  "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
6
  "main": "src/index.js",
6
7
  "bin": {
@@ -13,8 +14,9 @@
13
14
  "setup": "npm install && pip install -r tools/requirements.txt",
14
15
  "configure": "python tools/server-manager.py",
15
16
  "test-connection": "python tools/test-connection.py",
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": "npm run test:lockfile && npm run test:sudostdin && 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
18
  "test:lockfile": "node tests/test-lockfile.js",
19
+ "test:sudostdin": "node tests/test-sudo-stdin.js",
18
20
  "test:profiles": "node tests/test-profiles.js",
19
21
  "test:aliases": "node tests/test-command-aliases.js",
20
22
  "test:hooks": "node tests/test-hooks.js",
package/server.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.bvisible/mcp-ssh-manager",
4
+ "description": "SSH server management for agents, with per-server read-only and allowlist security modes",
5
+ "repository": {
6
+ "url": "https://github.com/bvisible/mcp-ssh-manager",
7
+ "source": "github"
8
+ },
9
+ "version": "3.8.2",
10
+ "packages": [
11
+ {
12
+ "registryType": "npm",
13
+ "identifier": "mcp-ssh-manager",
14
+ "version": "3.8.2",
15
+ "transport": {
16
+ "type": "stdio"
17
+ },
18
+ "environmentVariables": [
19
+ {
20
+ "name": "SSH_CONFIG_PATH",
21
+ "description": "Path to a TOML file holding the server definitions. Defaults to ~/.codex/ssh-config.toml. Each server can set MODE to readonly or restricted to constrain what the agent may run.",
22
+ "isRequired": false,
23
+ "isSecret": false,
24
+ "format": "filepath"
25
+ },
26
+ {
27
+ "name": "SSH_ENV_PATH",
28
+ "description": "Path to a .env file declaring servers as SSH_SERVER_<NAME>_HOST, _USER, _KEYPATH and friends. Defaults to a .env next to the package.",
29
+ "isRequired": false,
30
+ "isSecret": false,
31
+ "format": "filepath"
32
+ }
33
+ ]
34
+ }
35
+ ]
36
+ }
@@ -51,40 +51,40 @@ export function buildDeploymentStrategy(remotePath, options = {}) {
51
51
  strategy.requiresSudo = true;
52
52
  }
53
53
 
54
+ // A step that needs the sudo password carries it as `stdin`, never inside
55
+ // `command`. Interpolating it (`echo "<pass>" | sudo -S …`) published the
56
+ // password to the remote process list and /proc/<pid>/cmdline (issue #34).
57
+ // See the ssh_execute_sudo handler for what -S -k -p '' each do.
58
+ const sudoPrefix = sudoPassword ? "sudo -S -k -p '' " : 'sudo ';
59
+ const withSudoStdin = (step) => (sudoPassword ? { ...step, stdin: `${sudoPassword}\n` } : step);
60
+
54
61
  // Step 3: Copy from temp to final location
55
- const copyCmd = needsSudo && sudoPassword ?
56
- `echo "${sudoPassword}" | sudo -S cp {{tempFile}} "${remotePath}"` :
57
- needsSudo ?
58
- `sudo cp {{tempFile}} "${remotePath}"` :
59
- `cp {{tempFile}} "${remotePath}"`;
62
+ const copyCmd = needsSudo ?
63
+ `${sudoPrefix}cp {{tempFile}} "${remotePath}"` :
64
+ `cp {{tempFile}} "${remotePath}"`;
60
65
 
61
- strategy.steps.push({
66
+ strategy.steps.push(needsSudo ? withSudoStdin({
67
+ type: 'copy',
68
+ command: copyCmd
69
+ }) : {
62
70
  type: 'copy',
63
71
  command: copyCmd
64
72
  });
65
73
 
66
74
  // Step 4: Set ownership if specified
67
75
  if (owner) {
68
- const chownCmd = sudoPassword ?
69
- `echo "${sudoPassword}" | sudo -S chown ${owner} "${remotePath}"` :
70
- `sudo chown ${owner} "${remotePath}"`;
71
-
72
- strategy.steps.push({
76
+ strategy.steps.push(withSudoStdin({
73
77
  type: 'chown',
74
- command: chownCmd
75
- });
78
+ command: `${sudoPrefix}chown ${owner} "${remotePath}"`
79
+ }));
76
80
  }
77
81
 
78
82
  // Step 5: Set permissions if specified
79
83
  if (permissions) {
80
- const chmodCmd = sudoPassword ?
81
- `echo "${sudoPassword}" | sudo -S chmod ${permissions} "${remotePath}"` :
82
- `sudo chmod ${permissions} "${remotePath}"`;
83
-
84
- strategy.steps.push({
84
+ strategy.steps.push(withSudoStdin({
85
85
  type: 'chmod',
86
- command: chmodCmd
87
- });
86
+ command: `${sudoPrefix}chmod ${permissions} "${remotePath}"`
87
+ }));
88
88
  }
89
89
 
90
90
  // Step 6: Restart service if specified
package/src/index.js CHANGED
@@ -2284,7 +2284,14 @@ registerToolConditional(
2284
2284
  for (const step of strategy.steps) {
2285
2285
  const command = step.command.replace('{{tempFile}}', tempFile);
2286
2286
 
2287
- const result = await execCommandWithTimeout(ssh, command, { platform: deployServerConfig?.platform }, 15000);
2287
+ // step.stdin carries the sudo password for steps that need it, so it
2288
+ // never reaches the remote command line (issue #34).
2289
+ const result = await execCommandWithTimeout(
2290
+ ssh,
2291
+ command,
2292
+ { platform: deployServerConfig?.platform, stdin: step.stdin ?? null },
2293
+ 15000
2294
+ );
2288
2295
 
2289
2296
  if (result.code !== 0 && step.type !== 'backup') {
2290
2297
  throw new Error(`${step.type} failed: ${result.stderr}`);
@@ -2364,12 +2371,21 @@ registerToolConditional(
2364
2371
  fullCommand = `sudo ${fullCommand}`;
2365
2372
  }
2366
2373
 
2367
- // Add password if provided
2368
- if (password) {
2369
- fullCommand = `echo "${password}" | sudo -S ${command.replace(/^sudo /, '')}`;
2370
- } else if (serverConfig?.sudoPassword) {
2371
- // Use configured sudo password if available
2372
- fullCommand = `echo "${serverConfig.sudoPassword}" | sudo -S ${command.replace(/^sudo /, '')}`;
2374
+ // Add password if provided. The password travels on the exec channel's
2375
+ // stdin, never inside the command string: the previous
2376
+ // `echo "<pass>" | sudo -S …` left it readable in the remote process list
2377
+ // and /proc/<pid>/cmdline for anyone with an account on the host (#34).
2378
+ // -S read the password from stdin
2379
+ // -k invalidate any cached sudo timestamp first, so sudo always
2380
+ // consumes the password we wrote. Without it, an already-authorised
2381
+ // sudo skips the prompt and the password stays in the pipe, where
2382
+ // the command itself would read it as its own input.
2383
+ // -p '' suppress the prompt, which would otherwise land in stderr.
2384
+ let sudoStdin = null;
2385
+ const effectiveSudoPassword = password || serverConfig?.sudoPassword;
2386
+ if (effectiveSudoPassword) {
2387
+ fullCommand = `sudo -S -k -p '' ${command.replace(/^sudo /, '')}`;
2388
+ sudoStdin = `${effectiveSudoPassword}\n`;
2373
2389
  }
2374
2390
 
2375
2391
  // Add working directory if specified
@@ -2390,10 +2406,12 @@ registerToolConditional(
2390
2406
  }
2391
2407
  }
2392
2408
 
2393
- const result = await execCommandWithTimeout(ssh, fullCommand, { platform }, timeout);
2409
+ const result = await execCommandWithTimeout(ssh, fullCommand, { platform, stdin: sudoStdin }, timeout);
2394
2410
 
2395
- // Mask password in output for security
2396
- const maskedCommand = fullCommand.replace(/echo "[^"]+" \| sudo -S/, 'sudo');
2411
+ // The command string no longer carries the password, so there is nothing
2412
+ // left to mask — the flags are shown as-is. Kept as a named value so the
2413
+ // response format is unchanged for existing callers.
2414
+ const maskedCommand = fullCommand;
2397
2415
 
2398
2416
  return {
2399
2417
  content: [
@@ -188,7 +188,7 @@ class SSHManager {
188
188
  throw new Error('Not connected to SSH server');
189
189
  }
190
190
 
191
- const { timeout = 30000, cwd, rawCommand = false } = options;
191
+ const { timeout = 30000, cwd, rawCommand = false, stdin = null } = options;
192
192
  const fullCommand = (cwd && !rawCommand) ? `cd ${cwd} && ${command}` : command;
193
193
 
194
194
  return new Promise((resolve, reject) => {
@@ -238,6 +238,27 @@ class SSHManager {
238
238
 
239
239
  stream = streamObj;
240
240
 
241
+ // Feed the remote process on the exec channel's stdin. This is how the
242
+ // sudo password reaches `sudo -S` without ever appearing in the remote
243
+ // command line: interpolating it into `echo "..." | sudo -S` left it
244
+ // readable in `ps` and /proc/<pid>/cmdline for every account on the
245
+ // host, for the lifetime of the echo (issue #34). Closing the input
246
+ // afterwards tells sudo no more is coming; only done when a caller
247
+ // actually supplies stdin, so interactive commands are unaffected.
248
+ if (stdin !== null) {
249
+ try {
250
+ stream.write(stdin);
251
+ stream.end();
252
+ } catch (writeError) {
253
+ if (!completed) {
254
+ completed = true;
255
+ if (timeoutId) clearTimeout(timeoutId);
256
+ reject(writeError);
257
+ return;
258
+ }
259
+ }
260
+ }
261
+
241
262
  stream.on('close', (code, signal) => {
242
263
  if (!completed) {
243
264
  completed = true;