mcp-ssh-manager 4.0.3 → 4.2.0

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +199 -0
  2. package/CLAUDE.md +17 -5
  3. package/Formula/ssh-manager.rb +2 -2
  4. package/INSTALLATION.md +4 -0
  5. package/README.md +41 -5
  6. package/brand/README.md +1 -0
  7. package/cli/codex.js +67 -0
  8. package/cli/guard.js +69 -0
  9. package/cli/lib/config.sh +102 -37
  10. package/cli/ssh-manager +13 -0
  11. package/cli/ssh-manager.js +1 -1
  12. package/desktop/electron/electron-builder.yml +3 -0
  13. package/desktop/electron/locale.mjs +34 -0
  14. package/desktop/electron/main.js +52 -65
  15. package/desktop/electron/native-menu.mjs +44 -0
  16. package/desktop/electron/native.zh-CN.json +58 -0
  17. package/desktop/electron/package-lock.json +15 -40
  18. package/desktop/electron/package.json +4 -1
  19. package/desktop/electron/smoke-test.mjs +11 -1
  20. package/dist/ui/app.css +1 -1
  21. package/dist/ui/app.js +123 -115
  22. package/docs/MIGRATION.md +1 -1
  23. package/docs/SECURITY_MODES.md +15 -8
  24. package/docs/SEO.md +1 -1
  25. package/llms-install.md +97 -0
  26. package/package.json +17 -3
  27. package/scripts/check-action-pins.mjs +57 -0
  28. package/scripts/test-upgrade-from-published.mjs +24 -2
  29. package/server.json +2 -2
  30. package/src/audit.js +6 -15
  31. package/src/background-job.js +44 -0
  32. package/src/backup-manager.js +24 -29
  33. package/src/config-loader.js +10 -1
  34. package/src/database-manager.js +13 -31
  35. package/src/dump-guard.js +79 -0
  36. package/src/filtered-agent.js +53 -0
  37. package/src/health-monitor.js +8 -4
  38. package/src/index.js +216 -21
  39. package/src/logger.js +3 -1
  40. package/src/quiet-stderr.js +15 -0
  41. package/src/ssh-guard.js +344 -0
  42. package/src/ssh-manager.js +71 -2
  43. package/src/tunnel-manager.js +14 -4
package/CHANGELOG.md CHANGED
@@ -7,6 +7,205 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [4.2.0] - 2026-11-13
11
+
12
+ **A Chinese interface, a fuller audit log, and a guard against raw ssh.** Nothing
13
+ to change on upgrade: the guard and the background mode are off unless you use
14
+ them, and the audit log only gains lines when `AUDIT_LOG` is already on (the
15
+ release pipeline upgrades 3.8.5, 3.8.6, 3.8.7 and every 4.0.x and 4.1.x from the
16
+ registry to this version and back). Two things do behave differently without
17
+ being asked: a tool that fails now sets `isError` in its reply, and the interface
18
+ follows a Chinese system language until you choose one.
19
+
20
+ The Windows installer is still **not Authenticode-signed**, for the same reason
21
+ as 4.0.0: Windows shows *"Windows protected your PC"*, *More info → Run anyway*,
22
+ and `ssh-manager app` checks the installer against the SHA-256 in
23
+ `release-manifest-win32.json`. macOS builds are signed and notarized.
24
+
25
+ Many of these came from reading what the forks of this project changed: thanks
26
+ to @jaredshuai, @SEU-zhc, @fyq163 and @xutianhao6 for the work and the ideas.
27
+
28
+ ### Added
29
+
30
+ - **`ssh-manager codex setup` and `ssh-manager codex status`.** `setup` points
31
+ OpenAI Codex at this engine: only the `ssh-manager` table of
32
+ `~/.codex/config.toml` is replaced, the rest of the file stays, the entry names
33
+ the npm engine, and a second run changes nothing; without an npm install it says
34
+ how to get one and writes nothing. `status` says what Codex runs today. They were
35
+ documented (with `migrate`, `test` and `convert`, which have no meaning with the
36
+ V4 engine; `ssh-manager export servers.toml` writes the servers as TOML) and none
37
+ of them existed. The entry that `ConfigLoader.saveToCodexConfig` wrote named
38
+ `<current directory>/src/index.js`, a file that exists only in a source checkout,
39
+ so for an npm install Codex started no engine; it now names the module's own
40
+ folder. Found thanks to @jaredshuai's fork.
41
+ - **A Chinese interface (简体中文).** Options → Appearance has a *Language / 语言*
42
+ selector, for the desktop application and the web interface; the desktop menus,
43
+ dialogs and notifications follow it. Until you choose, the interface follows the
44
+ system language (Chinese for a `zh` locale, English for anything else), and the
45
+ choice is remembered. English is exactly as it was. Server names, commands,
46
+ paths and what a remote host prints are never translated. The translation is
47
+ @xutianhao6's, from his fork's community build: adapted here, completed for the
48
+ strings it missed and proofread. Thank you.
49
+ - **`ssh_execute` with `background: true`** starts a command detached from the
50
+ SSH session and returns at once with `{ pid, logFile }`, for a job that
51
+ outlives the timeout (a training run, a long build). Read its output with
52
+ `ssh_tail` (`follow: false`), check or stop it with `ssh_process_manager`.
53
+ The log file is never chosen by the caller: a free path would let a command
54
+ that passes the `readonly` policy overwrite any file the SSH user can write,
55
+ so the engine creates a private one with `mktemp`. The launcher works under a
56
+ csh or tcsh login shell; Windows targets are refused with a clear error. The
57
+ idea is @SEU-zhc's.
58
+ - **`ssh-manager guard`**, an opt-in hook for Claude Code that refuses (or, with
59
+ `--mode ask`, asks about) `ssh`, `scp`, `sftp` and a remote `rsync` run from the
60
+ agent's own shell, where the approval, the policy and the audit log do not
61
+ apply, and tells the agent which MCP tool to use. `install` edits only its own
62
+ entry in `~/.claude/settings.json` (a copy is kept the first time), `remove`
63
+ restores the file, `print` and `status` write nothing. It reads the command
64
+ text: a guard against accidents, not a security boundary. The idea is
65
+ @fyq163's, whose hook only reminded.
66
+ - **`SSH_LOG_STDERR=false`** keeps the engine silent on stderr, for a client that
67
+ draws a terminal interface on that stream (OpenCode and Kilo were the
68
+ reports). The log file still receives the log lines; nothing changes unless
69
+ the variable is set. The idea is @fyq163's.
70
+
71
+ ### Changed
72
+
73
+ - **With `AUDIT_LOG` set, every tool that targets the server records its
74
+ outcome**, not only a denial or an approval decision: `ssh_tail`, `ssh_sync`,
75
+ `ssh_deploy`, `ssh_db_*`, `ssh_backup_*`, `ssh_process_manager` and the rest now
76
+ leave a line with `success`, and `error` when they failed. A tool that records
77
+ its own exit code still writes exactly one line. Tools that only read local
78
+ state (server list, aliases, tunnel list) leave none. The design is
79
+ @jaredshuai's.
80
+ - **A tool that fails now says so in the MCP reply**: the 36 tools that answered
81
+ "❌ … failed" as plain text now also set `isError`, which is what a client
82
+ expects (and what the audit log needs to tell a failure from a success).
83
+
84
+ ### Fixed
85
+
86
+ - **A failed dump no longer reports success.** `mysqldump … | gzip > file` (and
87
+ `pg_dump`) reports the exit code of its last command: with a wrong password, a
88
+ missing database or a full disk the dump died, gzip still succeeded, and
89
+ `ssh_db_dump` and `ssh_backup_create` answered success with an empty archive of
90
+ 20 bytes. The cron script made by `ssh_backup_schedule` did the same every night,
91
+ and its retention cleanup then deleted the good archives. A dump that fails now
92
+ fails, with the dump program's own message, and leaves no file; the dump still
93
+ streams, with no temporary file. The cron script has `set -o pipefail`, removes a
94
+ failed archive and stops before the cleanup. Found thanks to @jaredshuai's fork.
95
+ - **A corrupt archive is no longer restored in part.** `gunzip -c dump.gz | mysql`
96
+ ran the database program on whatever gunzip had read, so a truncated archive was
97
+ restored half-way with no error. A gzip file is now tested whole before
98
+ `ssh_db_import` or `ssh_backup_restore` start the database program (MySQL and
99
+ PostgreSQL). A plain dump under a `.gz` name, which a backup made without
100
+ compression used to leave, is still restored.
101
+ - **A MongoDB backup can be restored.** It was written as `<id>.tar.gz` but
102
+ measured and restored as `<id>.gz`: a size of 0 and no way back. One place now
103
+ knows the path, a restore checks the file is there before it starts, and
104
+ archives made by older versions (they were already `<id>.tar.gz`) become
105
+ restorable. `ssh_db_dump` reports the path it really wrote.
106
+ - **`ssh-manager server remove prod` removes `prod`, not `prod_eu` too.** The CLI
107
+ matched a server's lines by the bare prefix `SSH_SERVER_PROD_`, which every
108
+ longer name starts with, so the other server lost its host, user and password.
109
+ Lines are now matched by the setting names the engine reads. Found thanks to
110
+ @jaredshuai's fork.
111
+ - **Editing a server from the CLI keeps its settings.** It deleted all the
112
+ server's lines and wrote seven back, so a read-only server became unrestricted:
113
+ its mode, allow and deny patterns, audit log, group and proxy jump were dropped.
114
+ Only the settings the wizard asks for are replaced now, in place.
115
+ - **A password with a `#` survives the CLI.** `ssh-manager server add` wrote
116
+ `a#b c"d` bare, and the engine read it back as `a` (dotenv starts a comment at
117
+ any `#`). A value is quoted only when dotenv would misread it, so every other
118
+ value is written exactly as before; one that cannot be carried is refused with a
119
+ reason and nothing is written.
120
+ - **The health check no longer counts container layers as disks.** On a Docker
121
+ host every `overlay` layer repeated the same usage, and `tmpfs`, `devtmpfs` and
122
+ `squashfs` mounts counted as full disks (a snap mount is always at 100 %), which
123
+ raised duplicate or false disk alerts. The check now records each mount's
124
+ filesystem type and skips those, keeping `/` even inside a container, and an
125
+ alert fires when usage reaches the threshold, not only when it passes it. In the
126
+ interface, the health card keeps long mount paths and alert text inside its
127
+ borders. Thanks to @xutianhao6.
128
+ - **Remote tunnels (`ssh_tunnel_create` with `type: "remote"`, `ssh -R`) never
129
+ worked**: they failed with `this.ssh.forwardIn is not a function`, because the
130
+ connection wrapper only had `forwardOut`. They work now, and closing one
131
+ cancels the forward and removes its listener. A failed creation is reported as
132
+ an error. Found thanks to @jaredshuai's fork.
133
+ - **Six simultaneous calls on a cold engine opened six SSH connections**, all kept
134
+ open and five of them unreachable, a burst of logins that a server's
135
+ `MaxStartups` or fail2ban can refuse. Callers now wait for the connection being
136
+ established; a failed attempt is not remembered. Found thanks to
137
+ @jaredshuai's fork.
138
+
139
+ ### Security
140
+
141
+ - **A database password no longer reaches the audit log or the approval request
142
+ in clear text.** `dbPassword` and `db_password` (taken by the backup, restore,
143
+ dump and import tools) were missing from a list of names to redact, so a
144
+ refused or approved call wrote the password into the audit file and showed it
145
+ in the approval request. The audit log now redacts any key that looks like a
146
+ secret, with the same rule as the logger. Found thanks to @jaredshuai's fork.
147
+
148
+ ## [4.1.0] - 2026-11-13
149
+
150
+ **Choose the agent key per server, and sudo in the audit log.** Nothing to
151
+ change on upgrade: the new option is off unless you set it, and the audit log
152
+ only gains lines when `AUDIT_LOG` is already on (the release pipeline upgrades
153
+ 3.8.5, 3.8.6, 3.8.7 and every 4.0.x from the registry to this version and back).
154
+
155
+ The Windows installer is still **not Authenticode-signed**, for the same reason
156
+ as 4.0.0: Windows shows *"Windows protected your PC"*, *More info → Run anyway*,
157
+ and `ssh-manager app` checks the installer against the SHA-256 in
158
+ `release-manifest-win32.json`. macOS builds are signed and notarized.
159
+
160
+ ### Added
161
+
162
+ - **Pick which key of the SSH agent a server uses** (#128, thanks to
163
+ @RebornOnce). When the agent holds many keys (a password manager's agent,
164
+ say), a server can hit `MaxAuthTries` and close the connection before the
165
+ right one is offered. `agent_public_key_path` in TOML, or
166
+ `SSH_SERVER_<NAME>_AGENT_PUBLIC_KEY_PATH` in `.env`, names a public key file:
167
+ only that identity is offered and used for signing, and the private key never
168
+ leaves the agent. If the agent does not hold it, the connection fails instead
169
+ of trying the others. It cannot be combined with a key, a password, a
170
+ certificate or agent forwarding, and nothing changes for servers without it.
171
+ `ssh_sync` uses the system's `ssh`, which takes `IdentityFile` and
172
+ `IdentitiesOnly yes` from your SSH configuration instead.
173
+ - **`llms-install.md`**: the steps an agent follows to set the server up for its
174
+ user (Node, the client entry, servers described in `~/.ssh-manager/.env` with
175
+ a key and never a password typed into the conversation, then a check). It is
176
+ what the Cline MCP Marketplace asks for, and any agent can follow it.
177
+
178
+ ### Fixed
179
+
180
+ - **The audit log records what `sudo` commands did** (#133, reported by
181
+ @revert12; #134, thanks to @orshih6). With `AUDIT_LOG` set, only
182
+ `ssh_execute` and `ssh_upload` wrote their outcome: a command run through
183
+ `ssh_execute_sudo` that the policy allowed left no line at all. It now records
184
+ the exit code and success (the logged arguments are the command and the
185
+ working directory, never the password), and so do `ssh_download`,
186
+ `ssh_execute_group` (one line per server) and commands sent to a persistent
187
+ session (success only: sessions report no exit code). Other tools still record
188
+ only a denial or an approval decision.
189
+
190
+ ### Security
191
+
192
+ - **The desktop build uses a fixed `minimatch`.** `electron-builder`, the tool
193
+ that builds the desktop app, pulled `minimatch` 10.2.6 and 9.0.9, open to a
194
+ denial of service through crafted glob patterns (GHSA-g3hv-75wg-m249). Nothing
195
+ was exposed: the tool only reads the patterns of our own build configuration,
196
+ and no copy of `minimatch` ships in the app or in the npm package. An npm
197
+ `overrides` entry in `desktop/electron/package.json` now resolves those copies
198
+ to 11.x; a build with it contains the same files as one without, the
199
+ `package.json` line aside. Remove the entry once `app-builder-lib` itself
200
+ requires `minimatch` 11.0.1 or later.
201
+
202
+ - **`@hono/node-server` 2.1.8 and `hono` 4.13.18 in the lockfile.** Two
203
+ moderate advisories for the first (GHSA-qv5m-9pm6-hqp3, GHSA-jpvv-r467-5p4w),
204
+ five for the second (four moderate, one low: GHSA-46wx-v44x-9hh2,
205
+ GHSA-4h7h-rv7c-7m2v, GHSA-4m76-xfj5-7975, GHSA-h7mg-cq63-vhpq,
206
+ GHSA-3gg2-335m-rxc6). The MCP SDK pulls both for its HTTP transport; the
207
+ stdio server this package runs never imports them, so nothing was exposed.
208
+
10
209
  ## [4.0.3] - 2026-11-05
11
210
 
12
211
  **A security release: upgrade.** `ssh_db_query` could run shell commands on
package/CLAUDE.md CHANGED
@@ -44,11 +44,9 @@ ssh-manager server show SERVER # Show server details
44
44
 
45
45
  ### OpenAI Codex Integration
46
46
  ```bash
47
- ssh-manager codex setup # Configure for Codex
48
- ssh-manager codex migrate # Convert servers to TOML
49
- ssh-manager codex test # Test Codex integration
50
- ssh-manager codex convert to-toml # Convert .env to TOML
51
- ssh-manager codex convert to-env # Convert TOML to .env
47
+ ssh-manager codex setup # Point Codex at this engine (~/.codex/config.toml)
48
+ ssh-manager codex status # What Codex runs today
49
+ ssh-manager export servers.toml # Servers as TOML (.toml, .env, .csv and .xlsx are written)
52
50
  ```
53
51
 
54
52
  ### Tool Management (NEW in v3.1)
@@ -185,6 +183,7 @@ SSH_SERVER_[NAME]_HOST=hostname
185
183
  SSH_SERVER_[NAME]_USER=username
186
184
  SSH_SERVER_[NAME]_PASSWORD=password # For password auth
187
185
  SSH_SERVER_[NAME]_KEYPATH=~/.ssh/key # For SSH key auth
186
+ SSH_SERVER_[NAME]_AGENT_PUBLIC_KEY_PATH=~/.ssh/id_ed25519.pub # Alternative: select one SSH_AUTH_SOCK identity
188
187
  SSH_SERVER_[NAME]_PASSPHRASE=passphrase # Optional, for passphrase-protected keys
189
188
  SSH_SERVER_[NAME]_PORT=22 # Optional
190
189
  SSH_SERVER_[NAME]_DEFAULT_DIR=/path # Optional default working directory
@@ -216,6 +215,19 @@ forward_agent = true # Optional: forward local ssh-agent t
216
215
  announce_agent = true # Optional: send AI_AGENT=mcp-ssh-manager to this host (off by default; false keeps it silent under the global switch)
217
216
  ```
218
217
 
218
+ ### Selecting an SSH agent key
219
+
220
+ Use `agent_public_key_path` in TOML or `SSH_SERVER_[NAME]_AGENT_PUBLIC_KEY_PATH` in `.env` (internal field: `agentPublicKeyPath`) to select a single public key from the existing agent at `SSH_AUTH_SOCK`:
221
+
222
+ ```toml
223
+ [ssh_servers.agent_host]
224
+ host = "example.com"
225
+ user = "admin"
226
+ agent_public_key_path = "~/.ssh/id_ed25519.pub"
227
+ ```
228
+
229
+ This works with compatible SSH agents, including compatible password-manager agents; signing stays in the agent. Missing or invalid public key files, an unavailable agent, or no matching identity fail authentication without falling back to other agent identities. Combining this option with `key_path`, `password`, `cert_path`, or enabled `forward_agent` is rejected. Without this option, existing authentication behavior is unchanged. `ssh_sync` uses system OpenSSH and does not apply this filter; configure `IdentityFile` and `IdentitiesOnly yes` separately in the SSH client configuration.
230
+
219
231
  ## Key Implementation Details
220
232
 
221
233
  1. **Connection Pooling**: The server maintains persistent SSH connections in a Map to avoid reconnection overhead (src/index.js:31)
@@ -13,8 +13,8 @@
13
13
  class SshManager < Formula
14
14
  desc "SSH server management for AI agents, with approval and audit"
15
15
  homepage "https://github.com/bvisible/mcp-ssh-manager"
16
- url "https://registry.npmjs.org/mcp-ssh-manager/-/mcp-ssh-manager-4.0.2.tgz"
17
- sha256 "cbe507a6ddfc2a33fdc5fd207c01fcf69357a02a6dce53ef69055889018ddbf2"
16
+ url "https://registry.npmjs.org/mcp-ssh-manager/-/mcp-ssh-manager-4.1.0.tgz"
17
+ sha256 "c0a5df702f4014aeb9f8b13b4bb91fcc2ed5433d6917ec14fb1d4cc59742bf74"
18
18
  license "MIT"
19
19
 
20
20
  depends_on "node"
package/INSTALLATION.md CHANGED
@@ -143,6 +143,10 @@ export SSH_MANAGER_ENV="/path/to/your/.env"
143
143
 
144
144
  # Optional: Set default log level
145
145
  export SSH_LOG_LEVEL="INFO"
146
+
147
+ # Optional: keep the engine silent on stderr, for a client that draws a terminal
148
+ # interface on it. The log file (SSH_LOG_FILE) still receives the log lines.
149
+ export SSH_LOG_STDERR=false
146
150
  ```
147
151
 
148
152
  ## 📦 Project Scope Installation
package/README.md CHANGED
@@ -20,8 +20,11 @@
20
20
  <div align="center">
21
21
 
22
22
  [![npm version](https://img.shields.io/npm/v/mcp-ssh-manager.svg?style=flat-square&logo=npm&color=c04500)](https://www.npmjs.com/package/mcp-ssh-manager)
23
+ [![Downloads](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fbvisible%2Fmcp-ssh-manager%2Fstats%2Fdownloads.json&style=flat-square)](docs/DOWNLOAD-STATS.md)
23
24
  [![npm downloads](https://img.shields.io/npm/dm/mcp-ssh-manager.svg?style=flat-square&logo=npm&color=c04500)](https://www.npmjs.com/package/mcp-ssh-manager)
24
- [![Version](https://img.shields.io/badge/release-4.0.3-c04500?style=flat-square)](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.3)
25
+ [![Desktop app downloads](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fbvisible%2Fmcp-ssh-manager%2Fstats%2Fdesktop.json&style=flat-square)](https://github.com/bvisible/mcp-ssh-manager/releases/latest)
26
+ [![GitHub stars](https://img.shields.io/github/stars/bvisible/mcp-ssh-manager?style=flat-square&color=c04500)](https://github.com/bvisible/mcp-ssh-manager/stargazers)
27
+ [![Version](https://img.shields.io/badge/release-4.2.0-c04500?style=flat-square)](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.2.0)
25
28
  [![Claude Code](https://img.shields.io/badge/Claude_Code-Compatible-5A67D8?style=flat-square&logo=anthropic)](https://claude.ai/code)
26
29
  [![OpenAI Codex](https://img.shields.io/badge/OpenAI_Codex-Compatible-00A67E?style=flat-square&logo=openai)](https://openai.com/codex)
27
30
  [![MCP](https://img.shields.io/badge/MCP-Server-orange?style=flat-square)](https://modelcontextprotocol.io)
@@ -54,17 +57,17 @@ An MCP SSH server is the most dangerous tool you can hand an agent: a shell on m
54
57
 
55
58
  ## Choose your workspace
56
59
 
57
- **Desktop application (`4.0.3`):** one installation with its own runtime,
60
+ **Desktop application (`4.2.0`):** one installation with its own runtime,
58
61
  terminal, file browser and server settings. No separate Node.js or npm
59
- installation. [Download it](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.3):
62
+ installation. [Download it](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.2.0):
60
63
 
61
64
  | Platform | File | Signature |
62
65
  |---|---|---|
63
66
  | macOS, Apple silicon / Intel | `…-arm64.dmg` / `…-x64.dmg` | **Signed and notarized by Apple** — opens normally |
64
- | Windows x64 / arm64 | `…-setup.exe` | **Not code-signed in 4.0.x.** Windows shows *"Windows protected your PC"*: *More info → Run anyway*. Check the file against the SHA-256 in `release-manifest-win32.json` on the release (`ssh-manager app` does it for you). Signing comes in a later release. |
67
+ | Windows x64 / arm64 | `…-setup.exe` | **Not code-signed yet.** Windows shows *"Windows protected your PC"*: *More info → Run anyway*. Check the file against the SHA-256 in `release-manifest-win32.json` on the release (`ssh-manager app` does it for you). Signing comes in a later release. |
65
68
  | Linux x64 | `.deb`, `.AppImage` | Unsigned, as Linux packages usually are |
66
69
 
67
- **Already using npm / the CLI?** `npm update -g mcp-ssh-manager` brings 4.0.3,
70
+ **Already using npm / the CLI?** `npm update -g mcp-ssh-manager` brings 4.2.0,
68
71
  and the V4 engine runs without an interface, from your existing `.env`, TOML or
69
72
  process variables — no automatic import, no forced wizard, no approval prompt
70
73
  unless you enable one per server. The one behaviour that tightens is **SSH
@@ -316,6 +319,19 @@ AES-256-GCM, master key in your OS keychain (a `0600` file where there is none
316
319
 
317
320
  **The key belongs to this machine.** A vault copied to a new laptop is ciphertext nobody can open — `vault backup` writes a copy encrypted under a passphrase you choose, which is what makes the move survivable. Your `.env` is never modified, not by `import`, not by the interface, and a setup half in each is a normal state rather than a broken one. Upgrading changes nothing on its own: see **[docs/MIGRATION.md](docs/MIGRATION.md)**.
318
321
 
322
+ ### Keep the agent on the tools
323
+
324
+ Approval, modes and the audit log only see what goes through these tools. An agent that also has a terminal can run `ssh prod rm -rf …` there and none of it applies. For Claude Code, an opt-in hook closes that door:
325
+
326
+ ```bash
327
+ ssh-manager guard install # refuse ssh, scp, sftp and remote rsync in the agent's shell
328
+ ssh-manager guard install --mode ask # …or ask you each time
329
+ ssh-manager guard print # show what it would write, change nothing
330
+ ssh-manager guard remove
331
+ ```
332
+
333
+ The agent is told why and which tool to use instead (`ssh_execute`, `ssh_upload`, `ssh_sync`, `ssh_tunnel_create`). It is a guard against accidents, not a security boundary: it reads the command text. Keep SSH keys and agent sockets away from the account the agent runs as. Nothing is installed unless you run `install`; it edits only its own entry in `~/.claude/settings.json`, and keeps a copy of the file as it was.
334
+
319
335
  ### The unglamorous parts, which are the ones that bite
320
336
 
321
337
  - **Your sudo password never reaches the remote command line.** It travels on the SSH channel's stdin, so it isn't visible in `ps`, in `/proc/<pid>/cmdline`, or in an `auditd` trail — unlike the `echo "$pass" | sudo -S` pattern common in this category ([#34](https://github.com/bvisible/mcp-ssh-manager/issues/34)).
@@ -508,6 +524,7 @@ SSH_SERVER_[NAME]_HOST=hostname_or_ip
508
524
  SSH_SERVER_[NAME]_USER=username
509
525
  SSH_SERVER_[NAME]_PASSWORD=password # or use a key
510
526
  SSH_SERVER_[NAME]_KEYPATH=~/.ssh/key
527
+ SSH_SERVER_[NAME]_AGENT_PUBLIC_KEY_PATH=~/.ssh/id_ed25519.pub # alternative: select one key from SSH_AUTH_SOCK
511
528
  SSH_SERVER_[NAME]_CERTPATH=~/.ssh/key-cert.pub # optional: OpenSSH certificate for KEYPATH
512
529
  SSH_SERVER_[NAME]_PASSPHRASE=key_passphrase # optional
513
530
  SSH_SERVER_[NAME]_PORT=22 # optional
@@ -552,6 +569,17 @@ user = "admin"
552
569
  proxy_jump = "bastion"
553
570
  ```
554
571
 
572
+ **Selecting an SSH agent key** — use a public key file to select one identity from the existing agent at `SSH_AUTH_SOCK`, including compatible password-manager agents. The private key stays in the agent, which performs signing. For example:
573
+
574
+ ```toml
575
+ [ssh_servers.agent_host]
576
+ host = "example.com"
577
+ user = "admin"
578
+ agent_public_key_path = "~/.ssh/id_ed25519.pub"
579
+ ```
580
+
581
+ The `.env` equivalent is `SSH_SERVER_[NAME]_AGENT_PUBLIC_KEY_PATH`; the internal configuration field is `agentPublicKeyPath`. This option fails if the public key file is missing or invalid, the agent is unavailable, or the agent does not offer a matching identity. It cannot be combined with `key_path`, `password`, `cert_path`, or enabled `forward_agent`; conflicting configuration is rejected. Omitting the option preserves the existing authentication behavior. `ssh_sync` uses system OpenSSH and does not apply this filter: configure its `IdentityFile` and `IdentitiesOnly yes` in your SSH client configuration separately.
582
+
555
583
  **OpenSSH user certificates** — for servers that trust a certificate authority (`TrustedUserCAKeys`), point `CERTPATH` / `cert_path` at the certificate signed for `KEYPATH` (usually `<key>-cert.pub`). It is read on every connection, so a short-lived certificate renewed on disk needs no restart, and a missing file fails the connection instead of falling back to the bare key. It takes effect once `ssh2` ships certificate support ([mscdex/ssh2#1495](https://github.com/mscdex/ssh2/pull/1495)); until then the plain key is offered, as before. `ssh_sync` uses the system `ssh`, which finds `<key>-cert.pub` next to the key on its own.
556
584
 
557
585
  **Loading order**, highest priority first: process environment → `.env` → the encrypted vault → TOML. A credential you deliberately put in the vault beats one left in a `.env`; an operator overriding for a single run still beats both.
@@ -685,6 +713,10 @@ The hero animation ships twice, light and dark, swapped by `<picture>` on `prefe
685
713
 
686
714
  ## What's new
687
715
 
716
+ **[4.2.0](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.2.0) — a Chinese interface, a fuller audit log, and a guard against raw ssh.** The interface and the desktop menus come in 简体中文 (*Options → Appearance → Language*; thanks to @xutianhao6). With `AUDIT_LOG` on, every tool now records what it did, not only a few. `ssh_execute` can start a long job in the background (`background: true`, an idea from @SEU-zhc), and the opt-in `ssh-manager guard` keeps an agent from running `ssh` in its own shell, where approval and audit do not apply (an idea from @fyq163). Fixed, thanks to @jaredshuai's fork: **backups that reported success when the dump had failed** (an empty archive, every night from `ssh_backup_schedule`), a corrupt archive restored in part, MongoDB backups that could not be restored, `ssh-manager server remove` deleting a look-alike server, editing a server turning read-only into unrestricted, remote tunnels that never worked, a database password in the audit log, and six simultaneous calls opening six connections. `ssh-manager codex setup` now exists. A tool that fails now sets `isError` in its reply. See the [CHANGELOG](CHANGELOG.md#420---2026-11-13).
717
+
718
+ **[4.1.0](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.1.0) — choose the agent key per server, and sudo in the audit log.** A server can name the one key of your SSH agent it uses, so an agent that holds many keys (a password manager's, say) no longer runs into `MaxAuthTries` before the right one is offered (thanks to @RebornOnce, [#128](https://github.com/bvisible/mcp-ssh-manager/pull/128)); with `AUDIT_LOG` on, `ssh_execute_sudo`, downloads, group commands and commands sent to a session now record what they did, never the sudo password ([#134](https://github.com/bvisible/mcp-ssh-manager/pull/134), thanks to @orshih6, reported by @revert12); [`llms-install.md`](llms-install.md) lets an agent set the server up for you; dependencies refreshed. Nothing to change on upgrade. See the [CHANGELOG](CHANGELOG.md#410---2026-11-13).
719
+
688
720
  **[4.0.3](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.3) — a security release; upgrade.** `ssh_db_query`, the read-only tool, could run shell commands on the server through the `psql` and `mysql` clients' own commands (`\!`), including on servers in `readonly` or `restricted` mode ([GHSA-qmf5-hrhv-5hjm](https://github.com/bvisible/mcp-ssh-manager/security/advisories/GHSA-qmf5-hrhv-5hjm), reported by @orshih6). Every version before it is affected. A MySQL query must now be one line without backslashes. See the [CHANGELOG](CHANGELOG.md#403---2026-11-05).
689
721
 
690
722
  **[4.0.2](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.2) — commands reach a Mac, and the desktop terminal is your own.** Commands sent to a macOS server no longer fail with `timeout: command not found` before they start (thanks to Henrik Tilly, [#115](https://github.com/bvisible/mcp-ssh-manager/pull/115)); the desktop terminal starts a login shell, so what Homebrew installed is found as in Terminal or Warp, and PowerShell on Windows; keystrokes reach the shell in the order they were typed; dependencies refreshed. Nothing to change on upgrade.
@@ -732,6 +764,10 @@ Made with ❤️ for the Claude Code community
732
764
 
733
765
  </div>
734
766
 
767
+ ## Also from us
768
+
769
+ **[Relais](https://github.com/bvisible/relais)**: several Claude accounts on one Mac, one workspace. Switch Claude Desktop and Claude Code between your work and personal accounts in one click, keep every conversation, and see each account's limits. Free and open source, for macOS.
770
+
735
771
  ## Validation before a release
736
772
 
737
773
  The [V4 testing guide](docs/TESTING-V4.md) describes the offline suites, real npm
package/brand/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  | `wordmark.svg` | The logo: **ssh** solid, **manager** outlined. Supplied, not derived. |
6
6
  | `icon.svg` | The app icon — the mark on its tile. Everything else is generated from this. |
7
7
  | `mark.svg` | The mark alone, no tile, `currentColor` for the white parts. |
8
+ | `logo-400.png` | The icon at 400×400, for directories that ask for one (the Cline MCP Marketplace). Rendered from `icon.svg`: `qlmanage -t -s 400 -o /tmp brand/icon.svg`. |
8
9
  | `social-preview.html` | The GitHub social preview (1280×640), rendered to `docs/images/social-preview.png` and `@2x` by `npm run brand:social`. The window in it is the README's own capture of the real application (`docs/images/v4-waiting-app.png`, made by the screenshot rig), so the image follows the interface when the rig is re-run. |
9
10
 
10
11
  ## The icon
package/cli/codex.js ADDED
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env node
2
+ // `ssh-manager codex` — point OpenAI Codex at this engine.
3
+ //
4
+ // ssh-manager codex setup Write Codex's ssh-manager entry (~/.codex/config.toml)
5
+ // ssh-manager codex status What Codex runs today
6
+ //
7
+ // It uses the same code as the interface's AI tools panel (src/agent-clients.js): only
8
+ // the ssh-manager table of the file is replaced, every other table and comment stays,
9
+ // and the entry names the engine that npm installed. The commands were documented
10
+ // (setup, migrate, test, convert) long before they existed; setup and status are the
11
+ // two that have a meaning with the V4 engine. Idea from jaredshuai's fork, which found
12
+ // the other way of writing the entry pointing into a source checkout.
13
+ //
14
+ // Native Node rather than Bash, so it works on Windows without Git Bash.
15
+ // Exit codes: 0 done, 1 could not, 2 a command that does not exist.
16
+ import { fileURLToPath } from 'node:url';
17
+ import { agentContext, agentsStatus, useEngine } from '../src/agent-clients.js';
18
+ import { BOLD, DIM, RESET } from './style.js';
19
+
20
+ const USAGE = `
21
+ ${BOLD}ssh-manager codex${RESET} — OpenAI Codex
22
+
23
+ ssh-manager codex setup Point Codex at this engine (the ssh-manager table of ~/.codex/config.toml)
24
+ ssh-manager codex status Whether Codex is installed and what its ssh-manager entry runs
25
+
26
+ ${DIM}Servers for Codex: ssh-manager export servers.toml writes them in TOML.${RESET}
27
+ `;
28
+
29
+ const describe = state => (state.engine === 'npm' ? 'the npm engine' : state.engine === 'app' ? "the desktop app's engine"
30
+ : state.engine === 'other' ? 'another ssh-manager (a checkout or a custom command)' : 'nothing yet');
31
+
32
+ /**
33
+ * @param {string[]} args
34
+ * @param {import('../src/agent-clients.js').Context} [context]
35
+ * @param {{ log: (text: string) => void, error: (text: string) => void }} [out]
36
+ * @returns {Promise<number>} the exit code
37
+ */
38
+ export async function codexCommand(args, context = agentContext(), out = console) {
39
+ const [command] = args;
40
+ if (!command || ['help', '-h', '--help'].includes(command)) { out.log(USAGE); return command ? 0 : 2; }
41
+ if (command !== 'setup' && command !== 'status') {
42
+ out.error(`Unknown command: codex ${command}\n${USAGE}`);
43
+ return 2;
44
+ }
45
+ try {
46
+ if (command === 'status') {
47
+ const state = (await agentsStatus(context)).clients.find(client => client.id === 'codex');
48
+ out.log(`Codex ${state.installed ? 'is installed' : 'was not found here'}; its ssh-manager entry runs ${describe(state)}${state.version ? ` ${state.version}` : ''}.`);
49
+ out.log(`${DIM}${state.configPath}${RESET}`);
50
+ return 0;
51
+ }
52
+ const state = await useEngine('codex', 'npm', context);
53
+ out.log(`Codex now runs ${describe(state)}${state.version ? ` ${state.version}` : ''}.`);
54
+ out.log(`${DIM}${state.configPath}${RESET}`);
55
+ out.log('Start a new Codex session for it to take effect.');
56
+ return 0;
57
+ } catch (error) {
58
+ out.error(error.message.includes('not installed with npm')
59
+ ? 'mcp-ssh-manager is not installed with npm here: run `npm install -g mcp-ssh-manager` first.'
60
+ : error.message);
61
+ return 1;
62
+ }
63
+ }
64
+
65
+ if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
66
+ codexCommand(process.argv.slice(2)).then(code => process.exit(code));
67
+ }
package/cli/guard.js ADDED
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env node
2
+ // ssh-manager guard: an opt-in Claude Code hook that refuses (or asks about) an
3
+ // `ssh`, `scp`, `sftp` or remote `rsync` run from the agent's shell, because it
4
+ // would skip the approval, the policy and the audit log of the MCP tools.
5
+ // Nothing is changed unless `install` is run; `print` shows what it would do.
6
+ import {
7
+ MODES, claudeSettingsPath, guardStatus, hookCommand, hookScriptPath, installGuard, removeGuard,
8
+ } from '../src/ssh-guard.js';
9
+
10
+ const HELP = `Usage: ssh-manager guard <command> [options]
11
+
12
+ Keep an AI agent from running ssh, scp, sftp or a remote rsync in its own shell,
13
+ where ssh-manager's approval, policy and audit log do not see it. Claude Code only.
14
+
15
+ Commands:
16
+ install Add the hook to Claude Code's settings (and copy its script)
17
+ remove Take the hook out again
18
+ status Say whether it is installed, and in which mode
19
+ print Show what install would write, and change nothing
20
+
21
+ Options:
22
+ --mode deny|ask deny (default) refuses the command and tells the agent to use
23
+ the MCP tools; ask lets you decide each time
24
+ --settings FILE Claude Code settings file (default: ~/.claude/settings.json,
25
+ or $CLAUDE_CONFIG_DIR/settings.json)
26
+ --delete-script With remove: also delete the copied script
27
+
28
+ This is a guard against accidents, not a security boundary: it reads the command
29
+ text. Keep SSH keys and agent sockets away from the account the agent runs as.
30
+ `;
31
+
32
+ function option(args, name) {
33
+ const index = args.indexOf(name);
34
+ return index === -1 ? undefined : args[index + 1];
35
+ }
36
+
37
+ const [command, ...args] = process.argv.slice(2);
38
+ const settingsFile = option(args, '--settings') || claudeSettingsPath();
39
+ const mode = option(args, '--mode') || 'deny';
40
+
41
+ try {
42
+ if (!command || ['help', '-h', '--help'].includes(command)) {
43
+ process.stdout.write(HELP);
44
+ } else if (command === 'install') {
45
+ if (!MODES.includes(mode)) throw new Error(`--mode must be one of ${MODES.join(', ')}`);
46
+ const done = installGuard({ mode, settingsFile });
47
+ console.log(`Installed in ${done.settingsFile} (mode: ${done.mode}).`);
48
+ console.log(`The hook script is ${done.script}.`);
49
+ console.log('Restart the Claude Code sessions that are open for it to apply.');
50
+ } else if (command === 'remove') {
51
+ const done = removeGuard({ settingsFile, deleteScript: args.includes('--delete-script') });
52
+ console.log(done.removed ? `Removed from ${done.settingsFile}.` : `Nothing to remove in ${done.settingsFile}.`);
53
+ } else if (command === 'status') {
54
+ const status = guardStatus({ settingsFile });
55
+ console.log(status.installed ? `Installed in ${status.settingsFile} (mode: ${status.mode}).` : `Not installed (${status.settingsFile}).`);
56
+ if (status.installed && !status.scriptPresent) console.log('The hook script is missing: run `ssh-manager guard install` again.');
57
+ } else if (command === 'print') {
58
+ if (!MODES.includes(mode)) throw new Error(`--mode must be one of ${MODES.join(', ')}`);
59
+ console.log(`Would add to ${settingsFile}:\n`);
60
+ console.log(JSON.stringify({ hooks: { PreToolUse: [{ matcher: 'Bash', hooks: [{ type: 'command', command: hookCommand(hookScriptPath(), mode) }] }] } }, null, 2));
61
+ console.log('\nNothing was changed.');
62
+ } else {
63
+ process.stderr.write(`Unknown command: ${command}\n\n${HELP}`);
64
+ process.exit(2);
65
+ }
66
+ } catch (error) {
67
+ process.stderr.write(`${error.message}\n`);
68
+ process.exit(1);
69
+ }