mcp-ssh-manager 3.8.3 → 3.8.5
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 +35 -0
- package/README.md +21 -10
- package/examples/{backup-workflow.js → backup-workflow.md} +129 -147
- package/package.json +4 -2
- package/scripts/setup-hooks.sh +16 -7
- package/scripts/validate.sh +23 -13
- package/server.json +2 -2
- package/src/backup-manager.js +68 -61
- package/src/config-loader.js +7 -4
- package/src/database-manager.js +2 -19
- package/src/health-monitor.js +20 -11
- package/src/index.js +21 -6
- package/src/logger.js +41 -2
- package/src/shell-quote.js +46 -0
- package/src/ssh-key-manager.js +11 -6
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,41 @@ 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.5] - 2026-08-28
|
|
9
|
+
|
|
10
|
+
### Security
|
|
11
|
+
|
|
12
|
+
Three reported advisories, all the same class of bug, all confirmed present in 3.8.4 and fixed here. The v3.6.7 fix (CVE-2026-77383) introduced `shellQuote()` but applied it to `src/database-manager.js` only; the parallel builders for backups and monitoring were never covered.
|
|
13
|
+
|
|
14
|
+
- **RCE through every `ssh_backup_*` builder** (GHSA-qwwm-vrm9-4mw8, high). `src/backup-manager.js` concatenated `database`, `dbUser`, `dbPassword`, `dbHost`, `backupDir`, `paths` and `exclude` into shell strings with no escaping — 0 uses of `shellQuote` across 9 builders. Arbitrary command execution as the SSH user on every managed server.
|
|
15
|
+
- **RCE through `ssh_db_dump` and the MongoDB backup path** (GHSA-796j-h5q5-jx6p, critical). The follow-up `stat` command interpolated `outputFile` raw, after the dump itself had been fixed — the earlier patch stopped one line short.
|
|
16
|
+
- **RCE bypassing readonly/restricted mode** (GHSA-m793-whw6-f537, critical). `ssh_service_status` and `ssh_tail` are read-only, so they stay enabled on servers the operator locked down — and neither quoted its arguments nor consulted the policy layer. `buildServiceStatusCommand` interpolated the service name unquoted six times; `ssh_tail` built `tail -n ${lines} "${file}" | grep "${grep}"` with double quotes only, so a `"` breakout ran. **This defeated the exact control those modes exist to provide**, and the README had just started advertising them.
|
|
17
|
+
|
|
18
|
+
Fixes: `shellQuote()` extracted to `src/shell-quote.js` and applied across `backup-manager.js` (54 call sites), `health-monitor.js` and the remaining inline commands in `index.js`; a `safeInteger()` helper for numeric arguments that still land in command strings; `buildProcessInfoCommand` now validates its PID like `buildKillProcessCommand` always did; and `ssh_tail` and `ssh_service_status` now call the policy layer.
|
|
19
|
+
|
|
20
|
+
Guarded by `npm run test:backupinjection`: **340 builder × argument × payload combinations** driven through a real `/bin/sh` with a canary file, asserting no payload ever executes. Verified by mutation — removing any single quote-call is caught.
|
|
21
|
+
|
|
22
|
+
**Upgrade if you use `ssh_backup_*`, `ssh_db_dump`, `ssh_service_status` or `ssh_tail`, and especially if you rely on `readonly` or `restricted` mode.**
|
|
23
|
+
|
|
24
|
+
## [3.8.4] - 2026-08-28
|
|
25
|
+
|
|
26
|
+
### Security
|
|
27
|
+
|
|
28
|
+
- **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`.
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- **`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.
|
|
33
|
+
- **`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.
|
|
34
|
+
- 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`.
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
|
|
38
|
+
- **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.
|
|
39
|
+
- **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.
|
|
40
|
+
- **Dependabot alerts and automated security fixes enabled** on the repository — they were switched off.
|
|
41
|
+
- 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.
|
|
42
|
+
|
|
8
43
|
## [3.8.3] - 2026-08-28
|
|
9
44
|
|
|
10
45
|
### Changed
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ A Model Context Protocol (MCP) server that enables **Claude Code** and **OpenAI
|
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/mcp-ssh-manager)
|
|
8
8
|
[](https://www.npmjs.com/package/mcp-ssh-manager)
|
|
9
|
-
[](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.8.5)
|
|
10
10
|
[](https://claude.ai/code)
|
|
11
11
|
[](https://openai.com/codex)
|
|
12
12
|
[](https://modelcontextprotocol.io)
|
|
@@ -23,16 +23,19 @@ 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.
|
|
26
|
+
## 🎉 What's New in v3.8.5
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
**🔒 Security release — three command-injection advisories fixed, one of which defeated `readonly` mode** (Released: August 28, 2026)
|
|
29
29
|
|
|
30
|
-
|
|
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
|
+
**Upgrade if you use `ssh_backup_*`, `ssh_db_dump`, `ssh_service_status` or `ssh_tail` — and especially if you rely on the `readonly` / `restricted` security modes.**
|
|
34
31
|
|
|
35
|
-
|
|
32
|
+
- **🔴 RCE bypassing `readonly` / `restricted`** (GHSA-m793-whw6-f537) — `ssh_service_status` and `ssh_tail` are read-only, so they stay enabled on servers you locked down, and neither quoted its arguments nor consulted the policy layer. A service name like `nginx; id > /tmp/pwned` executed. This defeated the exact control those modes exist to provide.
|
|
33
|
+
- **🔴 RCE through `ssh_db_dump`** (GHSA-796j-h5q5-jx6p) — the `stat` command run after the dump interpolated the output path raw. The v3.6.7 patch had stopped one line short.
|
|
34
|
+
- **🟠 RCE through every `ssh_backup_*` tool** (GHSA-qwwm-vrm9-4mw8) — `backup-manager.js` had **zero** shell escaping across its 9 builders, while `database-manager.js` had 95. The v3.6.7 fix was never extended to it.
|
|
35
|
+
|
|
36
|
+
The quoting helper now lives in one module (`src/shell-quote.js`) so "did this builder quote its inputs?" has a single answer, and a new test drives **340 builder × argument × payload combinations** through a real shell to prove none of them execute.
|
|
37
|
+
|
|
38
|
+
[Read full changelog →](CHANGELOG.md#385---2026-08-28)
|
|
36
39
|
|
|
37
40
|
---
|
|
38
41
|
|
|
@@ -75,7 +78,15 @@ Alongside that:
|
|
|
75
78
|
## Previous Releases
|
|
76
79
|
|
|
77
80
|
<details>
|
|
78
|
-
<summary><b>📜 Release history — v3.8.
|
|
81
|
+
<summary><b>📜 Release history — v3.8.4 down to v1.0.0</b> (click to expand)</summary>
|
|
82
|
+
|
|
83
|
+
### v3.8.4 - Secrets stop reaching the log, CodeQL on every commit (August 28, 2026)
|
|
84
|
+
|
|
85
|
+
- **🔒 The logger no longer writes secrets in clear text** — it writes to `~/.ssh-manager.log` and stderr (which your MCP host captures), so one call site handing it a server config would have persisted a production password. Redaction now happens inside the logger. Also: CodeQL on every push, every action pinned by SHA, and a broken example that never parsed. [Full changelog →](CHANGELOG.md#384---2026-08-28)
|
|
86
|
+
|
|
87
|
+
### v3.8.2 / v3.8.3 - Sudo password leak fixed, MCP Registry, signed releases (August 28, 2026)
|
|
88
|
+
|
|
89
|
+
- **🔒 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
90
|
|
|
80
91
|
### v3.8.1 - Reproducible installs and blocking quality gates (August 28, 2026)
|
|
81
92
|
|
|
@@ -1054,7 +1065,7 @@ See [docs/TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md) for complete guide.
|
|
|
1054
1065
|
"Backup website files excluding cache and logs"
|
|
1055
1066
|
```
|
|
1056
1067
|
|
|
1057
|
-
For detailed backup examples, see [examples/backup-workflow.
|
|
1068
|
+
For detailed backup examples, see [examples/backup-workflow.md](examples/backup-workflow.md) and [docs/BACKUP_GUIDE.md](docs/BACKUP_GUIDE.md).
|
|
1058
1069
|
|
|
1059
1070
|
### Using the Bash CLI
|
|
1060
1071
|
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
User
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "3.8.5",
|
|
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:backupinjection && 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",
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
"test:sync-path": "node tests/test-rsync-path.js",
|
|
34
35
|
"test:dbquoting": "node tests/test-database-query-quoting.js",
|
|
35
36
|
"test:dbinjection": "node tests/test-database-injection.js",
|
|
37
|
+
"test:backupinjection": "node tests/test-backup-monitor-injection.js",
|
|
36
38
|
"test:dbrowcount": "node tests/test-database-row-count.js",
|
|
37
39
|
"test:all": "npm test && npm run typecheck && ./scripts/validate.sh",
|
|
38
40
|
"validate": "./scripts/validate.sh",
|
package/scripts/setup-hooks.sh
CHANGED
|
@@ -16,17 +16,23 @@ if ! command -v node &> /dev/null; then
|
|
|
16
16
|
exit 1
|
|
17
17
|
fi
|
|
18
18
|
|
|
19
|
-
#
|
|
19
|
+
# Versions are pinned on purpose. An unpinned install in a setup script hands
|
|
20
|
+
# every contributor whatever version is current that day, and the tools below
|
|
21
|
+
# gate commits — a silent major bump changes what passes.
|
|
20
22
|
echo "📦 Installing pre-commit..."
|
|
21
|
-
pip install pre-commit
|
|
23
|
+
pip install 'pre-commit==4.0.1'
|
|
22
24
|
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
# eslint and prettier are already devDependencies, at versions the CI gates
|
|
26
|
+
# depend on. `npm install --save-dev eslint prettier` would re-resolve both to
|
|
27
|
+
# their latest majors (ESLint 10 over the pinned ^8.56.0) and rewrite
|
|
28
|
+
# package.json in the contributor's working tree. npm ci installs exactly what
|
|
29
|
+
# package-lock.json pins.
|
|
30
|
+
echo "📦 Installing Node.js dev dependencies from the lockfile..."
|
|
31
|
+
npm ci
|
|
26
32
|
|
|
27
33
|
# Install Python linting tools
|
|
28
34
|
echo "📦 Installing Python linting tools..."
|
|
29
|
-
pip install black flake8 isort
|
|
35
|
+
pip install 'black==24.10.0' 'flake8==7.1.1' 'isort==5.13.2'
|
|
30
36
|
|
|
31
37
|
# Install pre-commit hooks
|
|
32
38
|
echo "🔗 Installing git hooks..."
|
|
@@ -34,7 +40,10 @@ pre-commit install
|
|
|
34
40
|
|
|
35
41
|
# Create secrets baseline
|
|
36
42
|
echo "🔐 Creating secrets baseline..."
|
|
37
|
-
|
|
43
|
+
# Pinned: an unpinned install in a setup script gives every developer whatever
|
|
44
|
+
# version is current that day, and this one writes the secrets baseline the
|
|
45
|
+
# pre-commit hooks then trust.
|
|
46
|
+
pip install 'detect-secrets==1.5.0'
|
|
38
47
|
detect-secrets scan > .secrets.baseline
|
|
39
48
|
|
|
40
49
|
# Run hooks on all files (optional first run)
|