mcp-ssh-manager 3.8.2 → 3.8.4

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,37 @@ 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.4] - 2026-08-28
9
+
10
+ ### Security
11
+
12
+ - **The logger no longer writes secrets in clear text** (CodeQL `js/clear-text-logging`, `src/logger.js`). Structured log data is now redacted inside the logger rather than at each call site: any key matching password / passphrase / secret / token / credential / private key / api key / auth becomes `[redacted]`, at any depth, in arrays, whatever the casing. This matters because the logger writes to **two** places outside our control — `~/.ssh-manager.log` and stderr, which the MCP host captures — so one forgotten call site handing over a whole server config would have persisted a production password. Cyclic objects are marked rather than followed, so a self-referencing config cannot hang a log call. Guarded by `npm run test:redaction`.
13
+
14
+ ### Fixed
15
+
16
+ - **`examples/backup-workflow.js` did not parse at all**, and is now `examples/backup-workflow.md`. A cron expression (`*/6`) inside a `/* */` block closed the comment early. Repairing it exposed the deeper problem CodeQL then found (`js/call-to-non-callable`): the file called `createBackup(...)`, a function that does not exist anywhere — it was never a JavaScript API, but documentation of conversations with the agent, where the real operations are MCP tools (`ssh_backup_create`, …). Shipping it as executable `.js` in the npm tarball invited people to run something that could only throw. It is now Markdown, which is what it always was, with the illustrative nature stated at the top.
17
+ - **`scripts/validate.sh` now syntax-checks every tracked `.js` file** (49 instead of 2), which is how the above escaped for so long. The guard is itself verified by deliberately breaking a file.
18
+ - Two time-of-check/time-of-use races (CodeQL `js/file-system-race`): `ssh-key-manager.js` guarded `mkdirSync({recursive:true})` with an `existsSync` that was both redundant and racy, and `config-loader.js` checked for the Codex config before reading it instead of reading it and handling `ENOENT`.
19
+
20
+ ### Changed
21
+
22
+ - **Every GitHub action is pinned to a commit SHA**, including `trufflesecurity/trufflehog`, which tracked the moving `main` branch inside a workflow that reads the whole repository. This closes 17 of the 22 findings OpenSSF Scorecard reported.
23
+ - **CodeQL analysis added** (`security-and-quality`), answering Scorecard's SAST finding. It paid for itself immediately: every fix in this entry came out of its first run.
24
+ - **Dependabot alerts and automated security fixes enabled** on the repository — they were switched off.
25
+ - The `Release` workflow is re-runnable: it skips publishing when the version is already on the registry instead of failing on a duplicate, and creates the GitHub release if the SBOM step finds none.
26
+
27
+ ## [3.8.3] - 2026-08-28
28
+
29
+ ### Changed
30
+
31
+ - **First release published from CI with build provenance and an attested SBOM.** 3.8.2 shipped the workflow but was still published by hand, so it carried no attestation — `npm audit signatures` found none for it, while the comparable competitor had both an npm publish attestation and SLSA provenance. This release closes that gap for real: anyone can now verify which commit and which workflow built the tarball.
32
+ - **`zod` 3 → 4** ([#65](https://github.com/bvisible/mcp-ssh-manager/pull/65)). Verified before merging rather than after: with zod 4 installed, all 37 tools still register over a real MCP stdio handshake, and the full suite, typecheck and lint stay green. `@modelcontextprotocol/sdk` accepts `^3.25 || ^4.0`, and knip already wanted `^4.1.11`.
33
+ - `actions/checkout` and `actions/setup-node` bumped to v7 ([#61](https://github.com/bvisible/mcp-ssh-manager/pull/61), [#62](https://github.com/bvisible/mcp-ssh-manager/pull/62)).
34
+
35
+ ### Note
36
+
37
+ TypeScript 7 ([#64](https://github.com/bvisible/mcp-ssh-manager/issues/64)) and ESLint 10 ([#63](https://github.com/bvisible/mcp-ssh-manager/issues/63)) were declined, not deferred by accident: knip 5 pins `peer typescript ">=5.0.4 <7"`, and ESLint 9+ requires migrating off `.eslintrc` to flat config — tracked in [#66](https://github.com/bvisible/mcp-ssh-manager/issues/66).
38
+
8
39
  ## [3.8.2] - 2026-08-28
9
40
 
10
41
  ### Security
package/README.md CHANGED
@@ -6,7 +6,7 @@ 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.2-brightgreen?style=for-the-badge)](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.8.2)
9
+ [![Version](https://img.shields.io/badge/Version-3.8.4-brightgreen?style=for-the-badge)](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.8.4)
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)
@@ -23,16 +23,16 @@ A Model Context Protocol (MCP) server that enables **Claude Code** and **OpenAI
23
23
 
24
24
  ---
25
25
 
26
- ## 🎉 What's New in v3.8.2
26
+ ## 🎉 What's New in v3.8.4
27
27
 
28
- **🔐 The sudo password stops leaking to the remote process list, and the server joins the official MCP Registry** (Released: August 28, 2026)
28
+ **🔒 The logger stops writing secrets in clear text, and static analysis now runs on every commit** (Released: August 28, 2026)
29
29
 
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.
30
+ - **🔒 Security: secrets are redacted inside the logger.** It writes to two places outside your control — `~/.ssh-manager.log` and stderr, which your MCP host captures — so a single call site handing it a whole server config would have persisted a production password on disk. Redaction now happens structurally: any `password` / `passphrase` / `secret` / `token` / `credential` / private key / API key field becomes `[redacted]`, at any depth, in arrays, whatever the casing. No call site can leak one.
31
+ - **🔍 CodeQL runs on every push and pull request.** For a server that turns model output into shell commands on production hosts, "we read it carefully" is not an answer. It found every fix in this release on its first run — **`src/` now has zero open findings**.
32
+ - **🛡️ Every GitHub action pinned to a commit SHA**, including one that tracked a moving branch inside a workflow with read access to the whole repository. Closes 17 of the 22 OpenSSF Scorecard findings.
33
+ - **🐛 `examples/backup-workflow.js` never parsed** — a cron `*/6` inside a block comment closed it early — and called a function that does not exist. It was documentation, not a JavaScript API, and it shipped in the npm tarball. It is now `examples/backup-workflow.md`. `scripts/validate.sh` checks all 49 tracked `.js` files instead of 2, which is how that hid for months.
34
34
 
35
- [Read full changelog →](CHANGELOG.md#382---2026-08-28)
35
+ [Read full changelog →](CHANGELOG.md#384---2026-08-28)
36
36
 
37
37
  ---
38
38
 
@@ -75,7 +75,11 @@ Alongside that:
75
75
  ## Previous Releases
76
76
 
77
77
  <details>
78
- <summary><b>📜 Release history — v3.8.1 down to v1.0.0</b> (click to expand)</summary>
78
+ <summary><b>📜 Release history — v3.8.3 down to v1.0.0</b> (click to expand)</summary>
79
+
80
+ ### v3.8.2 / v3.8.3 - Sudo password leak fixed, MCP Registry, signed releases (August 28, 2026)
81
+
82
+ - **🔒 The sudo password no longer reaches the remote command line** ([#34](https://github.com/bvisible/mcp-ssh-manager/issues/34)) — it travelled through `echo "<password>" | sudo -S`, readable in `ps` and `/proc/<pid>/cmdline` by every account on the host. It now goes over the SSH channel's stdin. Also: listed in the **official MCP Registry** as `io.github.bvisible/mcp-ssh-manager`, releases published from CI with **SLSA provenance** and a CycloneDX SBOM, and the per-server security modes documented at last. [Full changelog →](CHANGELOG.md#383---2026-08-28)
79
83
 
80
84
  ### v3.8.1 - Reproducible installs and blocking quality gates (August 28, 2026)
81
85
 
@@ -1054,7 +1058,7 @@ See [docs/TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md) for complete guide.
1054
1058
  "Backup website files excluding cache and logs"
1055
1059
  ```
1056
1060
 
1057
- For detailed backup examples, see [examples/backup-workflow.js](examples/backup-workflow.js) and [docs/BACKUP_GUIDE.md](docs/BACKUP_GUIDE.md).
1061
+ For detailed backup examples, see [examples/backup-workflow.md](examples/backup-workflow.md) and [docs/BACKUP_GUIDE.md](docs/BACKUP_GUIDE.md).
1058
1062
 
1059
1063
  ### Using the Bash CLI
1060
1064
 
@@ -1,19 +1,19 @@
1
- /**
2
- * Backup Workflow Examples for MCP SSH Manager
3
- *
4
- * This file demonstrates various backup and restore workflows
5
- * that can be executed through Claude Code or OpenAI Codex.
6
- */
7
-
8
- // ============================================================================
9
- // EXAMPLE 1: Simple MySQL Backup Before Deployment
10
- // ============================================================================
11
-
12
- /*
13
- User: "Backup production database before deployment"
14
-
15
- AI executes:
16
- */
1
+ # Backup workflow examples
2
+
3
+ How to drive MCP SSH Manager's backup tools from Claude Code or OpenAI Codex.
4
+
5
+ > **These are illustrations, not a JavaScript API.** The snippets name the
6
+ > operations conceptually; what you actually call are the MCP tools
7
+ > (`ssh_backup_create`, `ssh_backup_list`, `ssh_backup_restore`,
8
+ > `ssh_backup_schedule`). Ask the agent in plain language — the
9
+ > **User:** lines below are what you type.
10
+
11
+ ## 1. Simple MySQL Backup Before Deployment
12
+
13
+ **User:** "Backup production database before deployment"
14
+
15
+ **AI executes:**
16
+ ```javascript
17
17
  const mysqlBackup = {
18
18
  tool: 'ssh_backup_create',
19
19
  params: {
@@ -26,22 +26,19 @@ const mysqlBackup = {
26
26
  retention: 7 // Keep for 7 days
27
27
  }
28
28
  };
29
+ ```
30
+ **Response:**
31
+ {
32
+ "success": true,
33
+ "backup_id": "mysql_pre-deployment_2025-10-01T10-30-45-000Z_abc123de",
34
+ "size_human": "50.00 MB",
35
+ "location": "/var/backups/ssh-manager/mysql_pre-deployment_2025-10-01T10-30-45-000Z_abc123de.gz"
36
+ }
37
+
38
+ ## 2. PostgreSQL Backup with Custom Retention
29
39
 
30
- // Response:
31
- // {
32
- // "success": true,
33
- // "backup_id": "mysql_pre-deployment_2025-10-01T10-30-45-000Z_abc123de",
34
- // "size_human": "50.00 MB",
35
- // "location": "/var/backups/ssh-manager/mysql_pre-deployment_2025-10-01T10-30-45-000Z_abc123de.gz"
36
- // }
37
-
38
- // ============================================================================
39
- // EXAMPLE 2: PostgreSQL Backup with Custom Retention
40
- // ============================================================================
41
-
42
- /*
43
- User: "Create PostgreSQL backup and keep it for 30 days"
44
- */
40
+ **User:** "Create PostgreSQL backup and keep it for 30 days"
41
+ ```javascript
45
42
  const postgresBackup = {
46
43
  tool: 'ssh_backup_create',
47
44
  params: {
@@ -55,14 +52,12 @@ const postgresBackup = {
55
52
  compress: true
56
53
  }
57
54
  };
55
+ ```
58
56
 
59
- // ============================================================================
60
- // EXAMPLE 3: Files Backup with Exclusions
61
- // ============================================================================
57
+ ## 3. Files Backup with Exclusions
62
58
 
63
- /*
64
- User: "Backup website files excluding cache and logs"
65
- */
59
+ **User:** "Backup website files excluding cache and logs"
60
+ ```javascript
66
61
  const filesBackup = {
67
62
  tool: 'ssh_backup_create',
68
63
  params: {
@@ -83,14 +78,12 @@ const filesBackup = {
83
78
  retention: 14
84
79
  }
85
80
  };
81
+ ```
86
82
 
87
- // ============================================================================
88
- // EXAMPLE 4: MongoDB Backup
89
- // ============================================================================
83
+ ## 4. MongoDB Backup
90
84
 
91
- /*
92
- User: "Backup MongoDB user database"
93
- */
85
+ **User:** "Backup MongoDB user database"
86
+ ```javascript
94
87
  const mongoBackup = {
95
88
  tool: 'ssh_backup_create',
96
89
  params: {
@@ -105,14 +98,12 @@ const mongoBackup = {
105
98
  retention: 7
106
99
  }
107
100
  };
101
+ ```
108
102
 
109
- // ============================================================================
110
- // EXAMPLE 5: List All Backups
111
- // ============================================================================
103
+ ## 5. List All Backups
112
104
 
113
- /*
114
- User: "Show me all MySQL backups on production"
115
- */
105
+ **User:** "Show me all MySQL backups on production"
106
+ ```javascript
116
107
  const listBackups = {
117
108
  tool: 'ssh_backup_list',
118
109
  params: {
@@ -120,32 +111,29 @@ const listBackups = {
120
111
  type: 'mysql' // Optional: filter by type
121
112
  }
122
113
  };
114
+ ```
115
+ **Response:**
116
+ {
117
+ "success": true,
118
+ "count": 5,
119
+ "backups": [
120
+ {
121
+ "id": "mysql_pre-deployment_2025-10-01T10-30-45-000Z_abc123de",
122
+ "type": "mysql",
123
+ "created_at": "2025-10-01T10:30:45.000Z",
124
+ "database": "myapp_prod",
125
+ "size_human": "50.00 MB",
126
+ "retention_days": 7
127
+ }
128
+ ]
129
+ }
130
+
131
+ ## 6. Restore from Backup
123
132
 
124
- // Response:
125
- // {
126
- // "success": true,
127
- // "count": 5,
128
- // "backups": [
129
- // {
130
- // "id": "mysql_pre-deployment_2025-10-01T10-30-45-000Z_abc123de",
131
- // "type": "mysql",
132
- // "created_at": "2025-10-01T10:30:45.000Z",
133
- // "database": "myapp_prod",
134
- // "size_human": "50.00 MB",
135
- // "retention_days": 7
136
- // }
137
- // ]
138
- // }
139
-
140
- // ============================================================================
141
- // EXAMPLE 6: Restore from Backup
142
- // ============================================================================
143
-
144
- /*
145
- User: "Restore the latest production backup"
146
- */
147
-
148
- // Step 1: List backups to find the ID
133
+ **User:** "Restore the latest production backup"
134
+
135
+ Step 1: List backups to find the ID
136
+ ```javascript
149
137
  const listFirst = {
150
138
  tool: 'ssh_backup_list',
151
139
  params: {
@@ -153,8 +141,9 @@ const listFirst = {
153
141
  type: 'mysql'
154
142
  }
155
143
  };
156
-
157
- // Step 2: Restore using the backup ID
144
+ ```
145
+ Step 2: Restore using the backup ID
146
+ ```javascript
158
147
  const restoreBackup = {
159
148
  tool: 'ssh_backup_restore',
160
149
  params: {
@@ -165,14 +154,12 @@ const restoreBackup = {
165
154
  dbPassword: process.env.DB_PASSWORD
166
155
  }
167
156
  };
157
+ ```
168
158
 
169
- // ============================================================================
170
- // EXAMPLE 7: Schedule Daily Backups
171
- // ============================================================================
159
+ ## 7. Schedule Daily Backups
172
160
 
173
- /*
174
- User: "Schedule daily MySQL backup at 2 AM"
175
- */
161
+ **User:** "Schedule daily MySQL backup at 2 AM"
162
+ ```javascript
176
163
  const scheduleDaily = {
177
164
  tool: 'ssh_backup_schedule',
178
165
  params: {
@@ -184,14 +171,12 @@ const scheduleDaily = {
184
171
  retention: 7 // Keep last 7 days
185
172
  }
186
173
  };
174
+ ```
187
175
 
188
- // ============================================================================
189
- // EXAMPLE 8: Schedule Weekly Full Backup
190
- // ============================================================================
176
+ ## 8. Schedule Weekly Full Backup
191
177
 
192
- /*
193
- User: "Schedule weekly full backup every Sunday at midnight"
194
- */
178
+ **User:** "Schedule weekly full backup every Sunday at midnight"
179
+ ```javascript
195
180
  const scheduleWeekly = {
196
181
  tool: 'ssh_backup_schedule',
197
182
  params: {
@@ -203,16 +188,14 @@ const scheduleWeekly = {
203
188
  retention: 30 // Keep for 4 weeks
204
189
  }
205
190
  };
191
+ ```
206
192
 
207
- // ============================================================================
208
- // EXAMPLE 9: Multi-Server Backup Strategy
209
- // ============================================================================
193
+ ## 9. Multi-Server Backup Strategy
210
194
 
211
- /*
212
- User: "Backup all production databases"
213
- */
195
+ **User:** "Backup all production databases"
214
196
 
215
- // Production MySQL
197
+ Production MySQL
198
+ ```javascript
216
199
  const prodMysql = {
217
200
  tool: 'ssh_backup_create',
218
201
  params: {
@@ -222,8 +205,9 @@ const prodMysql = {
222
205
  database: 'main_db'
223
206
  }
224
207
  };
225
-
226
- // Production PostgreSQL
208
+ ```
209
+ Production PostgreSQL
210
+ ```javascript
227
211
  const prodPostgres = {
228
212
  tool: 'ssh_backup_create',
229
213
  params: {
@@ -233,8 +217,9 @@ const prodPostgres = {
233
217
  database: 'analytics'
234
218
  }
235
219
  };
236
-
237
- // Production MongoDB
220
+ ```
221
+ Production MongoDB
222
+ ```javascript
238
223
  const prodMongo = {
239
224
  tool: 'ssh_backup_create',
240
225
  params: {
@@ -244,15 +229,13 @@ const prodMongo = {
244
229
  database: 'sessions'
245
230
  }
246
231
  };
232
+ ```
247
233
 
248
- // ============================================================================
249
- // EXAMPLE 10: Pre-Deployment Workflow
250
- // ============================================================================
251
-
252
- /*
234
+ ## 10. Pre-Deployment Workflow
235
+ ```javascript
253
236
  Complete deployment workflow with backup safety net
254
- */
255
-
237
+ ```
238
+ ```javascript
256
239
  async function preDeploymentWorkflow() {
257
240
  // Step 1: Create backup
258
241
  console.log("Creating pre-deployment backup...");
@@ -290,15 +273,12 @@ async function preDeploymentWorkflow() {
290
273
  console.log("Deployment successful!");
291
274
  }
292
275
  }
276
+ ```
293
277
 
294
- // ============================================================================
295
- // EXAMPLE 11: Disaster Recovery Workflow
296
- // ============================================================================
297
-
298
- /*
299
- User: "Recover production database from yesterday's backup"
300
- */
278
+ ## 11. Disaster Recovery Workflow
301
279
 
280
+ **User:** "Recover production database from yesterday's backup"
281
+ ```javascript
302
282
  async function disasterRecovery() {
303
283
  // Step 1: List all backups
304
284
  const backups = await listBackups({
@@ -328,15 +308,12 @@ async function disasterRecovery() {
328
308
 
329
309
  console.log("Recovery completed successfully");
330
310
  }
311
+ ```
331
312
 
332
- // ============================================================================
333
- // EXAMPLE 12: Backup to Remote Storage (S3)
334
- // ============================================================================
335
-
336
- /*
337
- User: "Backup database and upload to S3"
338
- */
313
+ ## 12. Backup to Remote Storage (S3)
339
314
 
315
+ **User:** "Backup database and upload to S3"
316
+ ```javascript
340
317
  async function backupToS3() {
341
318
  // Step 1: Create local backup
342
319
  const backup = await createBackup({
@@ -363,14 +340,12 @@ async function backupToS3() {
363
340
 
364
341
  console.log(`Backup uploaded to S3: s3://my-backups/${backup.backup_id}.gz`);
365
342
  }
343
+ ```
366
344
 
367
- // ============================================================================
368
- // EXAMPLE 13: Compliance Backup (90-day retention)
369
- // ============================================================================
345
+ ## 13. Compliance Backup (90-day retention)
370
346
 
371
- /*
372
- User: "Create compliance backup with 90-day retention"
373
- */
347
+ **User:** "Create compliance backup with 90-day retention"
348
+ ```javascript
374
349
  const complianceBackup = {
375
350
  tool: 'ssh_backup_create',
376
351
  params: {
@@ -382,8 +357,9 @@ const complianceBackup = {
382
357
  compress: true
383
358
  }
384
359
  };
385
-
386
- // Schedule monthly compliance backups
360
+ ```
361
+ Schedule monthly compliance backups
362
+ ```javascript
387
363
  const monthlyCompliance = {
388
364
  tool: 'ssh_backup_schedule',
389
365
  params: {
@@ -395,44 +371,49 @@ const monthlyCompliance = {
395
371
  retention: 365 // Keep for 1 year
396
372
  }
397
373
  };
374
+ ```
398
375
 
399
- // ============================================================================
400
- // CRON SCHEDULE REFERENCE
401
- // ============================================================================
402
-
403
- /*
376
+ ## Cron schedule reference
404
377
  Common cron schedules:
405
-
378
+ ```javascript
379
+ //
380
+ ```
406
381
  Daily:
407
382
  - "0 2 * * *" // Every day at 2 AM
408
383
  - "0 0 * * *" // Every day at midnight
409
-
384
+ ```javascript
385
+ //
386
+ ```
410
387
  Hourly:
411
388
  - "0 * * * *" // Every hour at minute 0
412
389
  - "0 */6 * * *" // Every 6 hours
413
-
390
+ ```javascript
391
+ //
392
+ ```
414
393
  Weekly:
415
394
  - "0 0 * * 0" // Every Sunday at midnight
416
395
  - "0 3 * * 1" // Every Monday at 3 AM
417
-
396
+ ```javascript
397
+ //
398
+ ```
418
399
  Monthly:
419
400
  - "0 0 1 * *" // 1st of month at midnight
420
401
  - "0 2 15 * *" // 15th of month at 2 AM
421
-
402
+ ```javascript
403
+ //
404
+ ```
422
405
  Weekdays:
423
406
  - "0 1 * * 1-5" // Mon-Fri at 1 AM
424
-
407
+ ```javascript
408
+ //
409
+ ```
425
410
  Custom:
426
411
  - "*/30 * * * *" // Every 30 minutes
427
412
  - "0 */4 * * *" // Every 4 hours
428
413
  - "0 9-17 * * *" // Every hour from 9 AM to 5 PM
429
- */
430
-
431
- // ============================================================================
432
- // NOTES
433
- // ============================================================================
434
414
 
435
- /*
415
+ ## Notes
416
+ ```javascript
436
417
  Best Practices:
437
418
 
438
419
  1. Security:
@@ -464,8 +445,8 @@ Best Practices:
464
445
  - Encrypt backups at rest
465
446
  - Maintain audit logs
466
447
  - Test disaster recovery procedures
467
- */
468
-
448
+ ```
449
+ ```javascript
469
450
  module.exports = {
470
451
  mysqlBackup,
471
452
  postgresBackup,
@@ -479,3 +460,4 @@ module.exports = {
479
460
  disasterRecovery,
480
461
  backupToS3
481
462
  };
463
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-ssh-manager",
3
- "version": "3.8.2",
3
+ "version": "3.8.4",
4
4
  "mcpName": "io.github.bvisible/mcp-ssh-manager",
5
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%",
6
6
  "main": "src/index.js",
@@ -14,9 +14,10 @@
14
14
  "setup": "npm install && pip install -r tools/requirements.txt",
15
15
  "configure": "python tools/server-manager.py",
16
16
  "test-connection": "python tools/test-connection.py",
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
+ "test": "npm run test:lockfile && npm run test:sudostdin && npm run test:redaction && 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",
18
18
  "test:lockfile": "node tests/test-lockfile.js",
19
19
  "test:sudostdin": "node tests/test-sudo-stdin.js",
20
+ "test:redaction": "node tests/test-logger-redaction.js",
20
21
  "test:profiles": "node tests/test-profiles.js",
21
22
  "test:aliases": "node tests/test-command-aliases.js",
22
23
  "test:hooks": "node tests/test-hooks.js",
@@ -94,7 +95,7 @@
94
95
  "@modelcontextprotocol/sdk": "^1.30.0",
95
96
  "dotenv": "^16.4.5",
96
97
  "ssh2": "^1.17.0",
97
- "zod": "^3.25.76"
98
+ "zod": "^4.4.3"
98
99
  },
99
100
  "devDependencies": {
100
101
  "eslint": "^8.56.0",
@@ -9,22 +9,32 @@ echo ""
9
9
 
10
10
  ERRORS=0
11
11
 
12
- # Check JavaScript syntax
13
- echo "📋 Checking JavaScript syntax..."
14
- if node --check src/index.js 2>/dev/null; then
15
- echo " ✅ JavaScript syntax is valid"
12
+ # Check JavaScript syntax across every tracked .js file.
13
+ # Previously this checked only src/index.js and src/ssh-manager.js, which is how
14
+ # examples/backup-workflow.js sat broken: a cron expression (*/6) inside a block
15
+ # comment closed it early, so the file never parsed. Examples are code people
16
+ # copy — they get checked too.
17
+ echo "📋 Checking JavaScript syntax (all tracked .js files)..."
18
+ JS_ERRORS=0
19
+ JS_COUNT=0
20
+ if git rev-parse --git-dir >/dev/null 2>&1; then
21
+ JS_FILES=$(git ls-files '*.js' | grep -v node_modules)
16
22
  else
17
- echo " ❌ JavaScript syntax error!"
18
- ERRORS=$((ERRORS + 1))
23
+ JS_FILES=$(find src cli tests examples debug -name '*.js' 2>/dev/null)
19
24
  fi
20
-
21
- # Check SSH Manager syntax
22
- echo "📋 Checking SSH Manager syntax..."
23
- if node --check src/ssh-manager.js 2>/dev/null; then
24
- echo " ✅ SSH Manager syntax is valid"
25
+ for f in $JS_FILES; do
26
+ [ -f "$f" ] || continue
27
+ JS_COUNT=$((JS_COUNT + 1))
28
+ if ! node --check "$f" 2>/dev/null; then
29
+ echo " ❌ syntax error: $f"
30
+ JS_ERRORS=$((JS_ERRORS + 1))
31
+ fi
32
+ done
33
+ if [ $JS_ERRORS -eq 0 ]; then
34
+ echo " ✅ JavaScript syntax is valid ($JS_COUNT files)"
25
35
  else
26
- echo " ❌ SSH Manager syntax error!"
27
- ERRORS=$((ERRORS + 1))
36
+ echo " ❌ $JS_ERRORS file(s) with syntax errors"
37
+ ERRORS=$((ERRORS + JS_ERRORS))
28
38
  fi
29
39
 
30
40
  # Check for .env in git
package/server.json CHANGED
@@ -6,12 +6,12 @@
6
6
  "url": "https://github.com/bvisible/mcp-ssh-manager",
7
7
  "source": "github"
8
8
  },
9
- "version": "3.8.2",
9
+ "version": "3.8.4",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "mcp-ssh-manager",
14
- "version": "3.8.2",
14
+ "version": "3.8.4",
15
15
  "transport": {
16
16
  "type": "stdio"
17
17
  },
@@ -395,10 +395,13 @@ export class ConfigLoader {
395
395
  /** @type {Record<string, any>} */
396
396
  let config = {};
397
397
 
398
- // Load existing config if it exists
399
- if (fs.existsSync(codexConfigPath)) {
400
- const content = fs.readFileSync(codexConfigPath, 'utf8');
401
- config = TOML.parse(content);
398
+ // Load existing config if it exists. Read first and handle ENOENT, rather
399
+ // than checking then reading: between the two the file can be replaced or
400
+ // removed, and the check buys nothing the error handling does not.
401
+ try {
402
+ config = TOML.parse(fs.readFileSync(codexConfigPath, 'utf8'));
403
+ } catch (error) {
404
+ if (error.code !== 'ENOENT') throw error;
402
405
  }
403
406
 
404
407
  // Add MCP server configuration
@@ -55,7 +55,7 @@ export function buildDeploymentStrategy(remotePath, options = {}) {
55
55
  // `command`. Interpolating it (`echo "<pass>" | sudo -S …`) published the
56
56
  // password to the remote process list and /proc/<pid>/cmdline (issue #34).
57
57
  // See the ssh_execute_sudo handler for what -S -k -p '' each do.
58
- const sudoPrefix = sudoPassword ? "sudo -S -k -p '' " : 'sudo ';
58
+ const sudoPrefix = sudoPassword ? 'sudo -S -k -p \'\' ' : 'sudo ';
59
59
  const withSudoStdin = (step) => (sudoPassword ? { ...step, stdin: `${sudoPassword}\n` } : step);
60
60
 
61
61
  // Step 3: Copy from temp to final location
package/src/logger.js CHANGED
@@ -35,6 +35,34 @@ const ICONS = {
35
35
  ERROR: '❌'
36
36
  };
37
37
 
38
+ // Field names whose values must never be written to a log, matched
39
+ // case-insensitively against the whole key (so `sudoPassword`, `SSH_PASSWORD`
40
+ // and `passphrase` are all caught).
41
+ const SECRET_KEY_PATTERN = /(pass(word|phrase)?|secret|token|credential|privatekey|private_key|apikey|api_key|auth)/i;
42
+ const REDACTED = '[redacted]';
43
+
44
+ /**
45
+ * Deep-copy a value with the value of any secret-looking key replaced.
46
+ * Cycles are broken so a self-referencing object cannot hang the logger.
47
+ * @param {any} value - Value to redact
48
+ * @param {WeakSet<object>} [seen] - Objects already visited on this path
49
+ * @returns {any} A redacted copy safe to serialise
50
+ */
51
+ function redactSecrets(value, seen = new WeakSet()) {
52
+ if (value === null || typeof value !== 'object') return value;
53
+ if (seen.has(value)) return '[circular]';
54
+ seen.add(value);
55
+
56
+ if (Array.isArray(value)) return value.map(item => redactSecrets(item, seen));
57
+
58
+ /** @type {Record<string, any>} */
59
+ const out = {};
60
+ for (const [key, item] of Object.entries(value)) {
61
+ out[key] = SECRET_KEY_PATTERN.test(key) ? REDACTED : redactSecrets(item, seen);
62
+ }
63
+ return out;
64
+ }
65
+
38
66
  class Logger {
39
67
  constructor() {
40
68
  // Set log level from environment variable
@@ -109,10 +137,15 @@ class Logger {
109
137
  // File format without colors
110
138
  const fileFormat = `[${timestamp}] [${levelName}] ${message}`;
111
139
 
112
- // Add data if present
140
+ // Add data if present, with secrets redacted first. This is deliberately
141
+ // done here rather than at each call site: a logger for an SSH manager will
142
+ // eventually be handed a whole server config, and one forgotten call would
143
+ // write a production password to ~/.ssh-manager.log and to stderr, where
144
+ // the MCP host captures it. Redacting structurally means no call site can
145
+ // leak one.
113
146
  let dataStr = '';
114
147
  if (Object.keys(data).length > 0) {
115
- dataStr = '\n ' + JSON.stringify(data, null, 2).replace(/\n/g, '\n ');
148
+ dataStr = '\n ' + JSON.stringify(redactSecrets(data), null, 2).replace(/\n/g, '\n ');
116
149
  }
117
150
 
118
151
  return {
@@ -154,9 +154,14 @@ export function removeHostKey(host, port = 22) {
154
154
  */
155
155
  export async function addHostKey(host, port = 22, keyData = null) {
156
156
  try {
157
- // Backup current known_hosts
158
- if (fs.existsSync(KNOWN_HOSTS_PATH)) {
157
+ // Backup current known_hosts. Copy first and treat "not there" as nothing
158
+ // to back up, rather than checking then copying: between the two calls the
159
+ // file can be replaced, and the check adds a race without preventing the
160
+ // failure it appears to guard against.
161
+ try {
159
162
  fs.copyFileSync(KNOWN_HOSTS_PATH, KNOWN_HOSTS_BACKUP);
163
+ } catch (error) {
164
+ if (error.code !== 'ENOENT') throw error;
160
165
  }
161
166
 
162
167
  // If no key data provided, fetch it
@@ -168,11 +173,11 @@ export async function addHostKey(host, port = 22, keyData = null) {
168
173
  keyData = fingerprints.map(fp => fp.fullKey).join('\n');
169
174
  }
170
175
 
171
- // Ensure .ssh directory exists
176
+ // Ensure .ssh directory exists. No existsSync guard: mkdirSync with
177
+ // recursive:true is already a no-op on an existing directory, and checking
178
+ // first only opens a window where the directory can change underneath us.
172
179
  const sshDir = path.dirname(KNOWN_HOSTS_PATH);
173
- if (!fs.existsSync(sshDir)) {
174
- fs.mkdirSync(sshDir, { mode: 0o700, recursive: true });
175
- }
180
+ fs.mkdirSync(sshDir, { mode: 0o700, recursive: true });
176
181
 
177
182
  // Append to known_hosts
178
183
  fs.appendFileSync(KNOWN_HOSTS_PATH, keyData + '\n');
@@ -1,96 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(mkdir:*)",
5
- "Bash(npm install)",
6
- "Bash(pip install:*)",
7
- "Bash(python tools/server-manager.py:*)",
8
- "Bash(python:*)",
9
- "Bash(mv:*)",
10
- "Bash(tree:*)",
11
- "Bash(timeout:*)",
12
- "Bash(npm install:*)",
13
- "Bash(npm ls:*)",
14
- "Bash(node test-mcp.js)",
15
- "Bash(node:*)",
16
- "WebFetch(domain:github.com)",
17
- "Bash(rm:*)",
18
- "Bash(cat:*)",
19
- "Bash(chmod:*)",
20
- "Bash(uv run:*)",
21
- "Bash(./test-claude-code.sh:*)",
22
- "Bash(git add:*)",
23
- "Bash(git commit:*)",
24
- "Bash(grep:*)",
25
- "Bash(git remote add:*)",
26
- "Bash(git push:*)",
27
- "Bash(./scripts/validate.sh:*)",
28
- "Bash(npm run test:all:*)",
29
- "mcp__ssh-manager__ssh_list_servers",
30
- "mcp__ssh-manager__ssh_execute",
31
- "mcp__ssh-manager__ssh_alias",
32
- "mcp__ide__getDiagnostics",
33
- "Bash(npm ci:*)",
34
- "Bash(npx eslint:*)",
35
- "Bash(npm run validate:*)",
36
- "Bash(git pull:*)",
37
- "Bash(npm test:*)",
38
- "Bash(black:*)",
39
- "Bash(flake8:*)",
40
- "Bash(gh run list:*)",
41
- "WebSearch",
42
- "Bash(git clone:*)",
43
- "Bash(echo:*)",
44
- "Bash(claude mcp:*)",
45
- "Bash(brew install:*)",
46
- "Bash(gh run view:*)",
47
- "Bash(git checkout:*)",
48
- "Bash(gh:*)",
49
- "Bash(SSH_VERBOSE:*)",
50
- "Bash(git cherry-pick:*)",
51
- "Bash(git merge:*)",
52
- "Bash(bash:*)",
53
- "Bash(./migrate.sh)",
54
- "Bash(SSH_MANAGER_ENV=\"/Users/jeremy/mcp/mcp-ssh-manager-fix/.env\" /Users/jeremy/.ssh-manager-cli/ssh-manager server list)",
55
- "Read(//Users/jeremy/.ssh-manager-cli/**)",
56
- "mcp__ssh-manager__ssh_upload",
57
- "mcp__ssh-manager__ssh_sync",
58
- "Bash(npm uninstall:*)",
59
- "mcp__ssh-manager__ssh_download",
60
- "Bash(SSH_MANAGER_ENV=\"/Users/jeremy/mcp/mcp-ssh-manager/.env\" bash -c 'source /Users/jeremy/.ssh-manager-cli/lib/config.sh && get_server_config \"\"efaje_production\"\" \"\"HOST\"\"')",
61
- "Bash(SSH_MANAGER_ENV=\"/Users/jeremy/mcp/mcp-ssh-manager/.env\" bash -c '\nsource /Users/jeremy/.ssh-manager-cli/lib/config.sh\nsource /Users/jeremy/.ssh-manager-cli/lib/menu.sh\n\n# Test avec un serveur qui n''''existe pas\nserver_name=\"\"efaje_production\"\"\nexisting_host=$(get_server_config \"\"$server_name\"\" \"\"HOST\"\" 2>/dev/null)\nif [ -n \"\"$existing_host\"\" ]; then\n echo \"\"ERREUR: Le serveur est d\\u00e9tect\\u00e9 comme existant\"\"\nelse\n echo \"\"OK: Le serveur n''''est pas d\\u00e9tect\\u00e9 comme existant\"\"\nfi\n\n# Test avec un serveur qui existe\nserver_name=\"\"efaje_staging\"\"\nexisting_host=$(get_server_config \"\"$server_name\"\" \"\"HOST\"\" 2>/dev/null)\nif [ -n \"\"$existing_host\"\" ]; then\n echo \"\"OK: Le serveur efaje_staging est bien d\\u00e9tect\\u00e9 (host: $existing_host)\"\"\nelse\n echo \"\"ERREUR: Le serveur efaje_staging n''''est pas d\\u00e9tect\\u00e9\"\"\nfi\n')",
62
- "Bash(git init:*)",
63
- "Bash(./build.sh:*)",
64
- "Bash(SSH_MANAGER_ENV=\"/Users/jeremy/mcp/mcp-ssh-manager/.env\" /Users/jeremy/.ssh-manager-cli/ssh-manager --version)",
65
- "Bash(git tag:*)",
66
- "Bash(readlink:*)",
67
- "Bash(SSH_MANAGER_ENV=\"/Users/jeremy/mcp/mcp-ssh-manager/.env\" bash -c '\nsource /Users/jeremy/.ssh-manager-cli/lib/config.sh\nserver=\"\"efaje_prod\"\"\nhost=$(get_server_config \"\"$server\"\" \"\"HOST\"\")\nif [ -n \"\"$host\"\" ]; then\n echo \"\"Server detected with host: $host\"\"\nelse\n echo \"\"Server not detected (host is empty)\"\"\nfi\n')",
68
- "Bash(npm start:*)",
69
- "Bash(ssh:*)",
70
- "Bash(npm run build:*)",
71
- "Read(//Users/jeremy/.ssh/**)",
72
- "Read(//Users/jeremy/.codex/**)",
73
- "Read(//Users/jeremy/.config/claude-code/**)",
74
- "Bash(SSH_MANAGER_ENV=\"/Users/jeremy/mcp/mcp-ssh-manager/.env\" /Users/jeremy/.ssh-manager-cli/ssh-manager codex)",
75
- "Bash(SSH_MANAGER_ENV=\"/Users/jeremy/mcp/mcp-ssh-manager/.env\" /Users/jeremy/.ssh-manager-cli/ssh-manager codex setup)",
76
- "Bash(SSH_MANAGER_ENV=\"/Users/jeremy/mcp/mcp-ssh-manager/.env\" /Users/jeremy/.ssh-manager-cli/ssh-manager codex migrate)",
77
- "Bash(SSH_MANAGER_ENV=\"/Users/jeremy/mcp/mcp-ssh-manager/.env\" /Users/jeremy/.ssh-manager-cli/ssh-manager codex test)",
78
- "Bash(SSH_CONFIG_PATH=/Users/jeremy/.codex/ssh-config.toml node --check src/index.js)",
79
- "Bash(ssh-manager:*)",
80
- "Bash(npm whoami:*)",
81
- "Bash(npm view:*)",
82
- "Bash(npm pack:*)",
83
- "Bash(npm publish:*)",
84
- "Bash(git rm:*)",
85
- "Bash(while read line_num rest)",
86
- "Bash(do sed -n \"$line_nums/.*''''\\([^'''']*\\)''''.*/\\1/p\" /Users/jeremy/mcp/mcp-ssh-manager/src/index.js done)",
87
- "Bash(sed:*)",
88
- "Bash(perl:*)",
89
- "Bash(git fetch:*)",
90
- "Bash(git -C /Users/jeremy/mcp/mcp-ssh-manager log:*)",
91
- "WebFetch(domain:www.npmjs.com)",
92
- "WebFetch(domain:glama.ai)"
93
- ],
94
- "deny": []
95
- }
96
- }