mcp-ssh-manager 3.1.3 → 3.1.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/CLAUDE.md +4 -0
- package/README.md +80 -8
- package/package.json +1 -1
- package/src/config-loader.js +8 -0
- package/src/index.js +20 -11
- package/src/ssh-manager.js +8 -0
package/CLAUDE.md
CHANGED
|
@@ -150,9 +150,11 @@ SSH_SERVER_[NAME]_HOST=hostname
|
|
|
150
150
|
SSH_SERVER_[NAME]_USER=username
|
|
151
151
|
SSH_SERVER_[NAME]_PASSWORD=password # For password auth
|
|
152
152
|
SSH_SERVER_[NAME]_KEYPATH=~/.ssh/key # For SSH key auth
|
|
153
|
+
SSH_SERVER_[NAME]_PASSPHRASE=passphrase # Optional, for passphrase-protected keys
|
|
153
154
|
SSH_SERVER_[NAME]_PORT=22 # Optional
|
|
154
155
|
SSH_SERVER_[NAME]_DEFAULT_DIR=/path # Optional default working directory
|
|
155
156
|
SSH_SERVER_[NAME]_SUDO_PASSWORD=pass # Optional for automated sudo
|
|
157
|
+
SSH_SERVER_[NAME]_PLATFORM=windows # Optional: "linux" (default) or "windows"
|
|
156
158
|
```
|
|
157
159
|
|
|
158
160
|
### TOML Format
|
|
@@ -162,9 +164,11 @@ host = "hostname"
|
|
|
162
164
|
user = "username"
|
|
163
165
|
password = "password" # For password auth
|
|
164
166
|
key_path = "~/.ssh/key" # For SSH key auth
|
|
167
|
+
passphrase = "key_passphrase" # Optional, for passphrase-protected keys
|
|
165
168
|
port = 22 # Optional
|
|
166
169
|
default_dir = "/path" # Optional default working directory
|
|
167
170
|
sudo_password = "pass" # Optional for automated sudo
|
|
171
|
+
platform = "windows" # Optional: "linux" (default) or "windows"
|
|
168
172
|
```
|
|
169
173
|
|
|
170
174
|
## Key Implementation Details
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ A powerful Model Context Protocol (MCP) server that enables **Claude Code** and
|
|
|
12
12
|
[](https://www.npmjs.com/package/mcp-ssh-manager)
|
|
13
13
|
[](https://github.com/bvisible/mcp-ssh-manager)
|
|
14
14
|
[](https://modelcontextprotocol.io)
|
|
15
|
-
[](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.1.5)
|
|
16
16
|
[](https://claude.ai/code)
|
|
17
17
|
[](https://openai.com/codex)
|
|
18
18
|
[](https://modelcontextprotocol.io)
|
|
@@ -32,17 +32,32 @@ A powerful Model Context Protocol (MCP) server that enables **Claude Code** and
|
|
|
32
32
|
|
|
33
33
|
---
|
|
34
34
|
|
|
35
|
-
## 🎉 What's New in v3.1.
|
|
35
|
+
## 🎉 What's New in v3.1.5
|
|
36
36
|
|
|
37
|
-
**
|
|
37
|
+
**SSH Agent & Passphrase-Protected Keys Support** (Released: March 5, 2026)
|
|
38
38
|
|
|
39
|
-
-
|
|
40
|
-
-
|
|
39
|
+
- **🔑 SSH Agent support**: Automatically uses `ssh-agent` when `SSH_AUTH_SOCK` is available — passphrase-protected keys work transparently
|
|
40
|
+
- **🔐 Passphrase configuration**: New `passphrase` field for both `.env` (`SSH_SERVER_FOO_PASSPHRASE`) and TOML (`passphrase = "..."`) formats
|
|
41
|
+
- **🔄 No regression**: Private keys are always passed to the connection alongside the agent — unencrypted keys continue to work even if not loaded in the agent
|
|
42
|
+
|
|
43
|
+
Thanks to [@snjax](https://github.com/snjax) for the original contribution ([#12](https://github.com/bvisible/mcp-ssh-manager/pull/12)).
|
|
41
44
|
|
|
42
45
|
---
|
|
43
46
|
|
|
44
47
|
## Previous Releases
|
|
45
48
|
|
|
49
|
+
### v3.1.4 - Windows SSH Host Support (February 22, 2026)
|
|
50
|
+
|
|
51
|
+
- **🪟 Windows SSH host fix**: Commands no longer fail on Windows hosts running OpenSSH ([#10](https://github.com/bvisible/mcp-ssh-manager/issues/10))
|
|
52
|
+
- New per-server `platform` config field (`SSH_SERVER_FOO_PLATFORM=windows` or `platform = "windows"` in TOML)
|
|
53
|
+
- When `platform=windows`, the Linux `timeout`/`sh -c` command wrapper is skipped and the SSH library's native timeout is used instead
|
|
54
|
+
- All tools (`ssh_execute`, `ssh_tail`, `ssh_monitor`, `ssh_deploy`, `ssh_execute_sudo`, `ssh_group_execute`) are platform-aware
|
|
55
|
+
|
|
56
|
+
### v3.1.2 - Windows Compatibility Fix (February 9, 2026)
|
|
57
|
+
|
|
58
|
+
- **🪟 Windows support**: Fixed crash on Windows where `process.env.HOME` is undefined ([#8](https://github.com/bvisible/mcp-ssh-manager/issues/8))
|
|
59
|
+
- Now uses `os.homedir()` for cross-platform compatibility (Linux, macOS, Windows)
|
|
60
|
+
|
|
46
61
|
### v3.1.0 - Tool Activation System (November 15, 2025)
|
|
47
62
|
|
|
48
63
|
### 🎯 Context Usage Optimization
|
|
@@ -98,7 +113,7 @@ This release adds **12 new MCP tools** transforming SSH Manager into a comprehen
|
|
|
98
113
|
|
|
99
114
|
### Core Features
|
|
100
115
|
- **🔗 Multiple SSH Connections** - Manage unlimited SSH servers from a single interface
|
|
101
|
-
- **🔐 Secure Authentication** - Support for
|
|
116
|
+
- **🔐 Secure Authentication** - Support for password, SSH key, and ssh-agent authentication (including passphrase-protected keys)
|
|
102
117
|
- **📁 File Operations** - Upload and download files between local and remote systems
|
|
103
118
|
- **⚡ Command Execution** - Run commands on remote servers with working directory support
|
|
104
119
|
- **📂 Default Directories** - Set default working directories per server for convenience
|
|
@@ -332,6 +347,7 @@ host = "prod.example.com"
|
|
|
332
347
|
user = "admin"
|
|
333
348
|
password = "secure_password" # or use key_path
|
|
334
349
|
key_path = "~/.ssh/id_rsa" # for SSH key auth (recommended)
|
|
350
|
+
passphrase = "key_passphrase" # optional, for passphrase-protected keys
|
|
335
351
|
port = 22
|
|
336
352
|
default_dir = "/var/www"
|
|
337
353
|
description = "Production server"
|
|
@@ -342,6 +358,14 @@ user = "deploy"
|
|
|
342
358
|
key_path = "~/.ssh/staging_key"
|
|
343
359
|
port = 2222
|
|
344
360
|
default_dir = "/home/deploy/app"
|
|
361
|
+
|
|
362
|
+
[ssh_servers.winhost]
|
|
363
|
+
host = "192.168.1.90"
|
|
364
|
+
user = "svc-ssh"
|
|
365
|
+
key_path = "~/.ssh/winhost_key"
|
|
366
|
+
port = 2222
|
|
367
|
+
platform = "windows"
|
|
368
|
+
description = "Windows host via OpenSSH"
|
|
345
369
|
```
|
|
346
370
|
|
|
347
371
|
💡 **See [examples/codex-ssh-config.example.toml](examples/codex-ssh-config.example.toml) for more complete examples!**
|
|
@@ -539,11 +563,13 @@ SSH_SERVER_[NAME]_HOST=hostname_or_ip
|
|
|
539
563
|
SSH_SERVER_[NAME]_USER=username
|
|
540
564
|
SSH_SERVER_[NAME]_PASSWORD=password # For password auth
|
|
541
565
|
SSH_SERVER_[NAME]_KEYPATH=~/.ssh/key # For SSH key auth
|
|
566
|
+
SSH_SERVER_[NAME]_PASSPHRASE=key_passphrase # Optional, for passphrase-protected keys
|
|
542
567
|
SSH_SERVER_[NAME]_PORT=22 # Optional, defaults to 22
|
|
543
568
|
SSH_SERVER_[NAME]_DEFAULT_DIR=/path/to/dir # Optional, default working directory
|
|
544
569
|
SSH_SERVER_[NAME]_DESCRIPTION=Description # Optional
|
|
570
|
+
SSH_SERVER_[NAME]_PLATFORM=windows # Optional: "linux" (default) or "windows"
|
|
545
571
|
|
|
546
|
-
# Example
|
|
572
|
+
# Example: Linux server
|
|
547
573
|
SSH_SERVER_PRODUCTION_HOST=prod.example.com
|
|
548
574
|
SSH_SERVER_PRODUCTION_USER=admin
|
|
549
575
|
SSH_SERVER_PRODUCTION_PASSWORD=secure_password
|
|
@@ -551,6 +577,14 @@ SSH_SERVER_PRODUCTION_PORT=22
|
|
|
551
577
|
SSH_SERVER_PRODUCTION_DEFAULT_DIR=/var/www/html
|
|
552
578
|
SSH_SERVER_PRODUCTION_DESCRIPTION=Production Server
|
|
553
579
|
SSH_SERVER_PRODUCTION_SUDO_PASSWORD=secure_sudo_pass # Optional, for automated deployments
|
|
580
|
+
|
|
581
|
+
# Example: Windows server (OpenSSH for Windows)
|
|
582
|
+
SSH_SERVER_WINHOST_HOST=192.168.1.90
|
|
583
|
+
SSH_SERVER_WINHOST_USER=svc-ssh
|
|
584
|
+
SSH_SERVER_WINHOST_KEYPATH=~/.ssh/winhost_key
|
|
585
|
+
SSH_SERVER_WINHOST_PORT=2222
|
|
586
|
+
SSH_SERVER_WINHOST_PLATFORM=windows
|
|
587
|
+
SSH_SERVER_WINHOST_DESCRIPTION=Windows host via OpenSSH
|
|
554
588
|
```
|
|
555
589
|
|
|
556
590
|
### Server Management Tool
|
|
@@ -611,6 +645,43 @@ claude mcp list
|
|
|
611
645
|
3. **Limit server access** - Use minimal required permissions
|
|
612
646
|
4. **Rotate credentials** - Update passwords and keys regularly
|
|
613
647
|
|
|
648
|
+
### 🔑 Passphrase-Protected SSH Keys
|
|
649
|
+
|
|
650
|
+
MCP SSH Manager supports passphrase-protected SSH keys in two ways:
|
|
651
|
+
|
|
652
|
+
**Option 1: SSH Agent (recommended)**
|
|
653
|
+
|
|
654
|
+
If your SSH key is loaded into `ssh-agent`, MCP SSH Manager will use it automatically — no configuration changes needed:
|
|
655
|
+
|
|
656
|
+
```bash
|
|
657
|
+
# Add your key to the agent (enter passphrase once)
|
|
658
|
+
ssh-add ~/.ssh/your_key
|
|
659
|
+
|
|
660
|
+
# Verify the key is loaded
|
|
661
|
+
ssh-add -l
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
The server detects the `SSH_AUTH_SOCK` environment variable and connects to the running agent. This is the same mechanism that regular `ssh` uses for GUI passphrase prompts.
|
|
665
|
+
|
|
666
|
+
**Option 2: Passphrase in configuration**
|
|
667
|
+
|
|
668
|
+
You can store the passphrase directly in the server config:
|
|
669
|
+
|
|
670
|
+
`.env` format:
|
|
671
|
+
```env
|
|
672
|
+
SSH_SERVER_MYSERVER_KEYPATH=~/.ssh/id_rsa
|
|
673
|
+
SSH_SERVER_MYSERVER_PASSPHRASE="your_passphrase"
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
TOML format:
|
|
677
|
+
```toml
|
|
678
|
+
[ssh_servers.myserver]
|
|
679
|
+
key_path = "~/.ssh/id_rsa"
|
|
680
|
+
passphrase = "your_passphrase"
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
> **Note:** SSH Agent is preferred over storing passphrases in config files for better security.
|
|
684
|
+
|
|
614
685
|
## 📚 Advanced Usage
|
|
615
686
|
|
|
616
687
|
### Documentation
|
|
@@ -819,7 +890,8 @@ Made with ❤️ for the Claude Code community
|
|
|
819
890
|
### Command Timeout
|
|
820
891
|
- The timeout parameter for SSH commands is advisory only
|
|
821
892
|
- Due to SSH2 library limitations, commands may continue running on the server even after timeout
|
|
822
|
-
-
|
|
893
|
+
- On Linux/macOS hosts, a system `timeout` wrapper is used for reliable command termination
|
|
894
|
+
- **Windows hosts**: Set `PLATFORM=windows` in your server config to skip the Linux `timeout`/`sh -c` wrapper (which is incompatible with Windows OpenSSH)
|
|
823
895
|
|
|
824
896
|
### SSH Sync (rsync)
|
|
825
897
|
- Password authentication requires `sshpass` to be installed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-ssh-manager",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5",
|
|
4
4
|
"description": "MCP SSH Manager: Model Context Protocol server for SSH remote server management. Control SSH connections from Claude Code and OpenAI Codex - execute commands, transfer files, database operations, backups, health monitoring, and DevOps automation. NEW: Tool activation system reduces context usage by 92%",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
package/src/config-loader.js
CHANGED
|
@@ -87,10 +87,12 @@ export class ConfigLoader {
|
|
|
87
87
|
user: serverConfig.user || serverConfig.username,
|
|
88
88
|
password: serverConfig.password,
|
|
89
89
|
keyPath: serverConfig.key_path || serverConfig.keypath || serverConfig.ssh_key,
|
|
90
|
+
passphrase: serverConfig.passphrase,
|
|
90
91
|
port: serverConfig.port || 22,
|
|
91
92
|
defaultDir: serverConfig.default_dir || serverConfig.default_directory || serverConfig.cwd,
|
|
92
93
|
sudoPassword: serverConfig.sudo_password,
|
|
93
94
|
description: serverConfig.description,
|
|
95
|
+
platform: serverConfig.platform ? serverConfig.platform.toLowerCase() : undefined,
|
|
94
96
|
source: 'toml'
|
|
95
97
|
});
|
|
96
98
|
}
|
|
@@ -133,10 +135,12 @@ export class ConfigLoader {
|
|
|
133
135
|
user: env[`SSH_SERVER_${match[1]}_USER`],
|
|
134
136
|
password: env[`SSH_SERVER_${match[1]}_PASSWORD`],
|
|
135
137
|
keyPath: env[`SSH_SERVER_${match[1]}_KEYPATH`],
|
|
138
|
+
passphrase: env[`SSH_SERVER_${match[1]}_PASSPHRASE`],
|
|
136
139
|
port: parseInt(env[`SSH_SERVER_${match[1]}_PORT`] || '22'),
|
|
137
140
|
defaultDir: env[`SSH_SERVER_${match[1]}_DEFAULT_DIR`],
|
|
138
141
|
sudoPassword: env[`SSH_SERVER_${match[1]}_SUDO_PASSWORD`],
|
|
139
142
|
description: env[`SSH_SERVER_${match[1]}_DESCRIPTION`],
|
|
143
|
+
platform: (env[`SSH_SERVER_${match[1]}_PLATFORM`] || '').toLowerCase() || undefined,
|
|
140
144
|
source: 'env'
|
|
141
145
|
};
|
|
142
146
|
|
|
@@ -184,9 +188,11 @@ export class ConfigLoader {
|
|
|
184
188
|
|
|
185
189
|
if (server.password) serverConfig.password = server.password;
|
|
186
190
|
if (server.keyPath) serverConfig.key_path = server.keyPath;
|
|
191
|
+
if (server.passphrase) serverConfig.passphrase = server.passphrase;
|
|
187
192
|
if (server.defaultDir) serverConfig.default_dir = server.defaultDir;
|
|
188
193
|
if (server.sudoPassword) serverConfig.sudo_password = server.sudoPassword;
|
|
189
194
|
if (server.description) serverConfig.description = server.description;
|
|
195
|
+
if (server.platform) serverConfig.platform = server.platform;
|
|
190
196
|
|
|
191
197
|
config.ssh_servers[name] = serverConfig;
|
|
192
198
|
}
|
|
@@ -209,10 +215,12 @@ export class ConfigLoader {
|
|
|
209
215
|
lines.push(`SSH_SERVER_${upperName}_USER=${server.user}`);
|
|
210
216
|
if (server.password) lines.push(`SSH_SERVER_${upperName}_PASSWORD="${server.password}"`);
|
|
211
217
|
if (server.keyPath) lines.push(`SSH_SERVER_${upperName}_KEYPATH=${server.keyPath}`);
|
|
218
|
+
if (server.passphrase) lines.push(`SSH_SERVER_${upperName}_PASSPHRASE="${server.passphrase}"`);
|
|
212
219
|
lines.push(`SSH_SERVER_${upperName}_PORT=${server.port || 22}`);
|
|
213
220
|
if (server.defaultDir) lines.push(`SSH_SERVER_${upperName}_DEFAULT_DIR=${server.defaultDir}`);
|
|
214
221
|
if (server.sudoPassword) lines.push(`SSH_SERVER_${upperName}_SUDO_PASSWORD="${server.sudoPassword}"`);
|
|
215
222
|
if (server.description) lines.push(`SSH_SERVER_${upperName}_DESCRIPTION="${server.description}"`);
|
|
223
|
+
if (server.platform) lines.push(`SSH_SERVER_${upperName}_PLATFORM=${server.platform}`);
|
|
216
224
|
lines.push('');
|
|
217
225
|
}
|
|
218
226
|
|
package/src/index.js
CHANGED
|
@@ -165,7 +165,8 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
165
165
|
const __dirname = path.dirname(__filename);
|
|
166
166
|
|
|
167
167
|
// Load environment variables (for backward compatibility)
|
|
168
|
-
|
|
168
|
+
const envFilePath = path.join(__dirname, '..', '.env');
|
|
169
|
+
dotenv.config({ path: envFilePath });
|
|
169
170
|
|
|
170
171
|
// Initialize logger
|
|
171
172
|
logger.info('MCP SSH Manager starting', {
|
|
@@ -176,7 +177,7 @@ logger.info('MCP SSH Manager starting', {
|
|
|
176
177
|
// Load SSH server configuration
|
|
177
178
|
let servers = {};
|
|
178
179
|
configLoader.load({
|
|
179
|
-
envPath:
|
|
180
|
+
envPath: envFilePath,
|
|
180
181
|
tomlPath: process.env.SSH_CONFIG_PATH,
|
|
181
182
|
preferToml: process.env.PREFER_TOML_CONFIG === 'true'
|
|
182
183
|
}).then(loadedServers => {
|
|
@@ -233,11 +234,13 @@ function loadServerConfig() {
|
|
|
233
234
|
|
|
234
235
|
// Execute command with timeout - using child_process timeout for real kill
|
|
235
236
|
async function execCommandWithTimeout(ssh, command, options = {}, timeoutMs = 30000) {
|
|
236
|
-
// Pass through rawCommand if specified
|
|
237
|
-
const { rawCommand, ...otherOptions } = options;
|
|
237
|
+
// Pass through rawCommand and platform if specified
|
|
238
|
+
const { rawCommand, platform, ...otherOptions } = options;
|
|
239
|
+
const isWindows = platform === 'windows';
|
|
238
240
|
|
|
239
241
|
// For commands that might hang, use the system's timeout command if available
|
|
240
|
-
|
|
242
|
+
// Skip for Windows hosts where the Linux timeout/sh commands don't exist
|
|
243
|
+
const useSystemTimeout = timeoutMs > 0 && timeoutMs < 300000 && !rawCommand && !isWindows; // Max 5 minutes, not for raw/Windows commands
|
|
241
244
|
|
|
242
245
|
if (useSystemTimeout) {
|
|
243
246
|
// Wrap command with timeout command (works on Linux/Mac)
|
|
@@ -482,7 +485,7 @@ registerToolConditional(
|
|
|
482
485
|
// Log command execution
|
|
483
486
|
const startTime = logger.logCommand(serverName, fullCommand, workingDir);
|
|
484
487
|
|
|
485
|
-
const result = await execCommandWithTimeout(ssh, fullCommand, {}, cappedTimeout);
|
|
488
|
+
const result = await execCommandWithTimeout(ssh, fullCommand, { platform: serverConfig?.platform }, cappedTimeout);
|
|
486
489
|
|
|
487
490
|
// Log command result
|
|
488
491
|
logger.logCommandResult(serverName, fullCommand, startTime, result);
|
|
@@ -1045,7 +1048,9 @@ registerToolConditional(
|
|
|
1045
1048
|
};
|
|
1046
1049
|
} else {
|
|
1047
1050
|
// Non-follow mode - just get the output
|
|
1048
|
-
const
|
|
1051
|
+
const tailServers = loadServerConfig();
|
|
1052
|
+
const tailServerConfig = tailServers[serverName.toLowerCase()];
|
|
1053
|
+
const result = await execCommandWithTimeout(ssh, command, { platform: tailServerConfig?.platform }, 15000);
|
|
1049
1054
|
|
|
1050
1055
|
if (result.code !== 0) {
|
|
1051
1056
|
throw new Error(result.stderr || 'Failed to tail file');
|
|
@@ -1152,10 +1157,12 @@ registerToolConditional(
|
|
|
1152
1157
|
|
|
1153
1158
|
// Execute all monitoring commands
|
|
1154
1159
|
const startTime = Date.now();
|
|
1160
|
+
const monServers = loadServerConfig();
|
|
1161
|
+
const monServerConfig = monServers[serverName.toLowerCase()];
|
|
1155
1162
|
|
|
1156
1163
|
for (const [key, cmd] of Object.entries(commands)) {
|
|
1157
1164
|
try {
|
|
1158
|
-
const result = await execCommandWithTimeout(ssh, cmd, {}, 10000);
|
|
1165
|
+
const result = await execCommandWithTimeout(ssh, cmd, { platform: monServerConfig?.platform }, 10000);
|
|
1159
1166
|
if (result.code === 0) {
|
|
1160
1167
|
output[key] = result.stdout.trim();
|
|
1161
1168
|
} else {
|
|
@@ -1658,7 +1665,7 @@ registerToolConditional(
|
|
|
1658
1665
|
const workingDir = cwd || serverConfig?.default_dir;
|
|
1659
1666
|
const fullCommand = workingDir ? `cd ${workingDir} && ${command}` : command;
|
|
1660
1667
|
|
|
1661
|
-
const execResult = await execCommandWithTimeout(ssh, fullCommand, {}, 30000);
|
|
1668
|
+
const execResult = await execCommandWithTimeout(ssh, fullCommand, { platform: serverConfig?.platform }, 30000);
|
|
1662
1669
|
|
|
1663
1670
|
return {
|
|
1664
1671
|
stdout: execResult.stdout,
|
|
@@ -1950,10 +1957,12 @@ registerToolConditional(
|
|
|
1950
1957
|
results.push(`✅ Uploaded ${path.basename(file.local)} to temp location`);
|
|
1951
1958
|
|
|
1952
1959
|
// Execute deployment strategy
|
|
1960
|
+
const deployServers = loadServerConfig();
|
|
1961
|
+
const deployServerConfig = deployServers[server.toLowerCase()];
|
|
1953
1962
|
for (const step of strategy.steps) {
|
|
1954
1963
|
const command = step.command.replace('{{tempFile}}', tempFile);
|
|
1955
1964
|
|
|
1956
|
-
const result = await execCommandWithTimeout(ssh, command, {}, 15000);
|
|
1965
|
+
const result = await execCommandWithTimeout(ssh, command, { platform: deployServerConfig?.platform }, 15000);
|
|
1957
1966
|
|
|
1958
1967
|
if (result.code !== 0 && step.type !== 'backup') {
|
|
1959
1968
|
throw new Error(`${step.type} failed: ${result.stderr}`);
|
|
@@ -2042,7 +2051,7 @@ registerToolConditional(
|
|
|
2042
2051
|
fullCommand = `cd ${serverConfig.default_dir} && ${fullCommand}`;
|
|
2043
2052
|
}
|
|
2044
2053
|
|
|
2045
|
-
const result = await execCommandWithTimeout(ssh, fullCommand, {}, timeout);
|
|
2054
|
+
const result = await execCommandWithTimeout(ssh, fullCommand, { platform: serverConfig?.platform }, timeout);
|
|
2046
2055
|
|
|
2047
2056
|
// Mask password in output for security
|
|
2048
2057
|
const maskedCommand = fullCommand.replace(/echo "[^"]+" \| sudo -S/, 'sudo');
|
package/src/ssh-manager.js
CHANGED
|
@@ -98,11 +98,19 @@ class SSHManager {
|
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
// Use ssh-agent if available (handles passphrase-protected keys transparently)
|
|
102
|
+
if (process.env.SSH_AUTH_SOCK) {
|
|
103
|
+
connConfig.agent = process.env.SSH_AUTH_SOCK;
|
|
104
|
+
}
|
|
105
|
+
|
|
101
106
|
// Add authentication (support both keyPath and keypath for compatibility)
|
|
102
107
|
const keyPath = this.config.keyPath || this.config.keypath;
|
|
103
108
|
if (keyPath) {
|
|
104
109
|
const resolvedKeyPath = keyPath.replace('~', os.homedir());
|
|
105
110
|
connConfig.privateKey = fs.readFileSync(resolvedKeyPath);
|
|
111
|
+
if (this.config.passphrase) {
|
|
112
|
+
connConfig.passphrase = this.config.passphrase;
|
|
113
|
+
}
|
|
106
114
|
} else if (this.config.password) {
|
|
107
115
|
connConfig.password = this.config.password;
|
|
108
116
|
}
|