mcp-ssh-manager 3.1.4 → 3.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.
package/CLAUDE.md CHANGED
@@ -150,10 +150,12 @@ 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
156
157
  SSH_SERVER_[NAME]_PLATFORM=windows # Optional: "linux" (default) or "windows"
158
+ SSH_SERVER_[NAME]_PROXYJUMP=bastion # Optional: name of another server to use as jump host
157
159
  ```
158
160
 
159
161
  ### TOML Format
@@ -163,10 +165,12 @@ host = "hostname"
163
165
  user = "username"
164
166
  password = "password" # For password auth
165
167
  key_path = "~/.ssh/key" # For SSH key auth
168
+ passphrase = "key_passphrase" # Optional, for passphrase-protected keys
166
169
  port = 22 # Optional
167
170
  default_dir = "/path" # Optional default working directory
168
171
  sudo_password = "pass" # Optional for automated sudo
169
172
  platform = "windows" # Optional: "linux" (default) or "windows"
173
+ proxy_jump = "bastion" # Optional: name of another server to use as jump host
170
174
  ```
171
175
 
172
176
  ## 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
  [![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)
13
13
  [![MCP SSH Server](https://img.shields.io/badge/MCP_SSH-Server-orange?style=for-the-badge)](https://github.com/bvisible/mcp-ssh-manager)
14
14
  [![SSH MCP](https://img.shields.io/badge/SSH_MCP-Compatible-blue?style=for-the-badge)](https://modelcontextprotocol.io)
15
- [![Version](https://img.shields.io/badge/Version-3.1.2-brightgreen?style=for-the-badge)](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.1.2)
15
+ [![Version](https://img.shields.io/badge/Version-3.2.0-brightgreen?style=for-the-badge)](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v3.2.0)
16
16
  [![Claude Code](https://img.shields.io/badge/Claude_Code-Compatible-5A67D8?style=for-the-badge&logo=anthropic)](https://claude.ai/code)
17
17
  [![OpenAI Codex](https://img.shields.io/badge/OpenAI_Codex-Compatible-00A67E?style=for-the-badge&logo=openai)](https://openai.com/codex)
18
18
  [![MCP](https://img.shields.io/badge/MCP-Server-orange?style=for-the-badge)](https://modelcontextprotocol.io)
@@ -32,17 +32,40 @@ 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.2
35
+ ## 🎉 What's New in v3.2.0
36
36
 
37
- **Windows Compatibility Fix** (Released: February 9, 2026)
37
+ **SSH ProxyJump / Bastion Host Support & npx Fix** (Released: March 18, 2026)
38
38
 
39
- - **🪟 Windows support**: Fixed crash on Windows where `process.env.HOME` is undefined ([#8](https://github.com/bvisible/mcp-ssh-manager/issues/8))
40
- - Now uses `os.homedir()` for cross-platform compatibility (Linux, macOS, Windows)
39
+ - **🔀 ProxyJump support**: Connect to servers behind bastion/jump hosts with a simple `PROXYJUMP` config field ([#15](https://github.com/bvisible/mcp-ssh-manager/issues/15))
40
+ - Chain multiple jumps (A → B → C) via recursive connections
41
+ - Circular dependency detection prevents infinite loops
42
+ - All tools work transparently through jump hosts (execute, upload, download, sync...)
43
+ - Jump connections are pooled and reused like direct connections
44
+ - **📦 npx support fixed**: Added `bin` field to `package.json` — `npx mcp-ssh-manager` now works correctly ([#14](https://github.com/bvisible/mcp-ssh-manager/issues/14))
41
45
 
42
46
  ---
43
47
 
44
48
  ## Previous Releases
45
49
 
50
+ ### v3.1.5 - SSH Agent & Passphrase Support (March 5, 2026)
51
+
52
+ - **🔑 SSH Agent support**: Automatically uses `ssh-agent` when `SSH_AUTH_SOCK` is available — passphrase-protected keys work transparently
53
+ - **🔐 Passphrase configuration**: New `passphrase` field for both `.env` and TOML formats
54
+
55
+ Thanks to [@snjax](https://github.com/snjax) for the original contribution ([#12](https://github.com/bvisible/mcp-ssh-manager/pull/12)).
56
+
57
+ ### v3.1.4 - Windows SSH Host Support (February 22, 2026)
58
+
59
+ - **🪟 Windows SSH host fix**: Commands no longer fail on Windows hosts running OpenSSH ([#10](https://github.com/bvisible/mcp-ssh-manager/issues/10))
60
+ - New per-server `platform` config field (`SSH_SERVER_FOO_PLATFORM=windows` or `platform = "windows"` in TOML)
61
+ - When `platform=windows`, the Linux `timeout`/`sh -c` command wrapper is skipped and the SSH library's native timeout is used instead
62
+ - All tools (`ssh_execute`, `ssh_tail`, `ssh_monitor`, `ssh_deploy`, `ssh_execute_sudo`, `ssh_group_execute`) are platform-aware
63
+
64
+ ### v3.1.2 - Windows Compatibility Fix (February 9, 2026)
65
+
66
+ - **🪟 Windows support**: Fixed crash on Windows where `process.env.HOME` is undefined ([#8](https://github.com/bvisible/mcp-ssh-manager/issues/8))
67
+ - Now uses `os.homedir()` for cross-platform compatibility (Linux, macOS, Windows)
68
+
46
69
  ### v3.1.0 - Tool Activation System (November 15, 2025)
47
70
 
48
71
  ### 🎯 Context Usage Optimization
@@ -98,7 +121,8 @@ This release adds **12 new MCP tools** transforming SSH Manager into a comprehen
98
121
 
99
122
  ### Core Features
100
123
  - **🔗 Multiple SSH Connections** - Manage unlimited SSH servers from a single interface
101
- - **🔐 Secure Authentication** - Support for both password and SSH key authentication
124
+ - **🔐 Secure Authentication** - Support for password, SSH key, and ssh-agent authentication (including passphrase-protected keys)
125
+ - **🔀 ProxyJump / Bastion Host** - Connect to servers behind jump hosts with chained multi-hop support
102
126
  - **📁 File Operations** - Upload and download files between local and remote systems
103
127
  - **⚡ Command Execution** - Run commands on remote servers with working directory support
104
128
  - **📂 Default Directories** - Set default working directories per server for convenience
@@ -332,6 +356,7 @@ host = "prod.example.com"
332
356
  user = "admin"
333
357
  password = "secure_password" # or use key_path
334
358
  key_path = "~/.ssh/id_rsa" # for SSH key auth (recommended)
359
+ passphrase = "key_passphrase" # optional, for passphrase-protected keys
335
360
  port = 22
336
361
  default_dir = "/var/www"
337
362
  description = "Production server"
@@ -342,6 +367,26 @@ user = "deploy"
342
367
  key_path = "~/.ssh/staging_key"
343
368
  port = 2222
344
369
  default_dir = "/home/deploy/app"
370
+
371
+ [ssh_servers.winhost]
372
+ host = "192.168.1.90"
373
+ user = "svc-ssh"
374
+ key_path = "~/.ssh/winhost_key"
375
+ port = 2222
376
+ platform = "windows"
377
+ description = "Windows host via OpenSSH"
378
+
379
+ [ssh_servers.bastion]
380
+ host = "bastion.example.com"
381
+ user = "jumpuser"
382
+ key_path = "~/.ssh/bastion_key"
383
+
384
+ [ssh_servers.internal]
385
+ host = "10.0.0.5"
386
+ user = "admin"
387
+ key_path = "~/.ssh/internal_key"
388
+ proxy_jump = "bastion"
389
+ description = "Private server behind bastion"
345
390
  ```
346
391
 
347
392
  💡 **See [examples/codex-ssh-config.example.toml](examples/codex-ssh-config.example.toml) for more complete examples!**
@@ -539,11 +584,14 @@ SSH_SERVER_[NAME]_HOST=hostname_or_ip
539
584
  SSH_SERVER_[NAME]_USER=username
540
585
  SSH_SERVER_[NAME]_PASSWORD=password # For password auth
541
586
  SSH_SERVER_[NAME]_KEYPATH=~/.ssh/key # For SSH key auth
587
+ SSH_SERVER_[NAME]_PASSPHRASE=key_passphrase # Optional, for passphrase-protected keys
542
588
  SSH_SERVER_[NAME]_PORT=22 # Optional, defaults to 22
543
589
  SSH_SERVER_[NAME]_DEFAULT_DIR=/path/to/dir # Optional, default working directory
544
590
  SSH_SERVER_[NAME]_DESCRIPTION=Description # Optional
591
+ SSH_SERVER_[NAME]_PLATFORM=windows # Optional: "linux" (default) or "windows"
592
+ SSH_SERVER_[NAME]_PROXYJUMP=bastion # Optional: name of another server to use as jump host
545
593
 
546
- # Example
594
+ # Example: Linux server
547
595
  SSH_SERVER_PRODUCTION_HOST=prod.example.com
548
596
  SSH_SERVER_PRODUCTION_USER=admin
549
597
  SSH_SERVER_PRODUCTION_PASSWORD=secure_password
@@ -551,6 +599,25 @@ SSH_SERVER_PRODUCTION_PORT=22
551
599
  SSH_SERVER_PRODUCTION_DEFAULT_DIR=/var/www/html
552
600
  SSH_SERVER_PRODUCTION_DESCRIPTION=Production Server
553
601
  SSH_SERVER_PRODUCTION_SUDO_PASSWORD=secure_sudo_pass # Optional, for automated deployments
602
+
603
+ # Example: Windows server (OpenSSH for Windows)
604
+ SSH_SERVER_WINHOST_HOST=192.168.1.90
605
+ SSH_SERVER_WINHOST_USER=svc-ssh
606
+ SSH_SERVER_WINHOST_KEYPATH=~/.ssh/winhost_key
607
+ SSH_SERVER_WINHOST_PORT=2222
608
+ SSH_SERVER_WINHOST_PLATFORM=windows
609
+ SSH_SERVER_WINHOST_DESCRIPTION=Windows host via OpenSSH
610
+
611
+ # Example: Server behind a bastion/jump host
612
+ SSH_SERVER_BASTION_HOST=bastion.example.com
613
+ SSH_SERVER_BASTION_USER=jumpuser
614
+ SSH_SERVER_BASTION_KEYPATH=~/.ssh/bastion_key
615
+
616
+ SSH_SERVER_INTERNAL_HOST=10.0.0.5
617
+ SSH_SERVER_INTERNAL_USER=admin
618
+ SSH_SERVER_INTERNAL_KEYPATH=~/.ssh/internal_key
619
+ SSH_SERVER_INTERNAL_PROXYJUMP=bastion
620
+ SSH_SERVER_INTERNAL_DESCRIPTION=Private server behind bastion
554
621
  ```
555
622
 
556
623
  ### Server Management Tool
@@ -611,8 +678,76 @@ claude mcp list
611
678
  3. **Limit server access** - Use minimal required permissions
612
679
  4. **Rotate credentials** - Update passwords and keys regularly
613
680
 
681
+ ### 🔑 Passphrase-Protected SSH Keys
682
+
683
+ MCP SSH Manager supports passphrase-protected SSH keys in two ways:
684
+
685
+ **Option 1: SSH Agent (recommended)**
686
+
687
+ If your SSH key is loaded into `ssh-agent`, MCP SSH Manager will use it automatically — no configuration changes needed:
688
+
689
+ ```bash
690
+ # Add your key to the agent (enter passphrase once)
691
+ ssh-add ~/.ssh/your_key
692
+
693
+ # Verify the key is loaded
694
+ ssh-add -l
695
+ ```
696
+
697
+ 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.
698
+
699
+ **Option 2: Passphrase in configuration**
700
+
701
+ You can store the passphrase directly in the server config:
702
+
703
+ `.env` format:
704
+ ```env
705
+ SSH_SERVER_MYSERVER_KEYPATH=~/.ssh/id_rsa
706
+ SSH_SERVER_MYSERVER_PASSPHRASE="your_passphrase"
707
+ ```
708
+
709
+ TOML format:
710
+ ```toml
711
+ [ssh_servers.myserver]
712
+ key_path = "~/.ssh/id_rsa"
713
+ passphrase = "your_passphrase"
714
+ ```
715
+
716
+ > **Note:** SSH Agent is preferred over storing passphrases in config files for better security.
717
+
614
718
  ## 📚 Advanced Usage
615
719
 
720
+ ### ProxyJump / Bastion Host
721
+
722
+ Connect to servers behind a bastion or jump host. The connection is tunneled through the jump server transparently — all tools (execute, upload, download, sync) work as usual.
723
+
724
+ ```env
725
+ # Define the bastion server
726
+ SSH_SERVER_BASTION_HOST=bastion.example.com
727
+ SSH_SERVER_BASTION_USER=jumpuser
728
+ SSH_SERVER_BASTION_KEYPATH=~/.ssh/bastion_key
729
+
730
+ # Point the target server to the bastion
731
+ SSH_SERVER_PRIVATE_HOST=10.0.0.5
732
+ SSH_SERVER_PRIVATE_USER=admin
733
+ SSH_SERVER_PRIVATE_PROXYJUMP=bastion
734
+ ```
735
+
736
+ Or in TOML:
737
+ ```toml
738
+ [ssh_servers.bastion]
739
+ host = "bastion.example.com"
740
+ user = "jumpuser"
741
+ key_path = "~/.ssh/bastion_key"
742
+
743
+ [ssh_servers.private]
744
+ host = "10.0.0.5"
745
+ user = "admin"
746
+ proxy_jump = "bastion"
747
+ ```
748
+
749
+ **Chained jumps** are supported: if `bastion` itself has a `proxy_jump`, the chain is followed recursively. Circular references are detected and rejected.
750
+
616
751
  ### Documentation
617
752
  - [DEPLOYMENT_GUIDE.md](docs/DEPLOYMENT_GUIDE.md) - Deployment strategies and permission handling
618
753
  - [ALIASES_AND_HOOKS.md](docs/ALIASES_AND_HOOKS.md) - Command aliases and automation hooks
@@ -819,7 +954,8 @@ Made with ❤️ for the Claude Code community
819
954
  ### Command Timeout
820
955
  - The timeout parameter for SSH commands is advisory only
821
956
  - Due to SSH2 library limitations, commands may continue running on the server even after timeout
822
- - For critical timeout needs, use the system's `timeout` command directly in your command
957
+ - On Linux/macOS hosts, a system `timeout` wrapper is used for reliable command termination
958
+ - **Windows hosts**: Set `PLATFORM=windows` in your server config to skip the Linux `timeout`/`sh -c` wrapper (which is incompatible with Windows OpenSSH)
823
959
 
824
960
  ### SSH Sync (rsync)
825
961
  - Password authentication requires `sshpass` to be installed
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "mcp-ssh-manager",
3
- "version": "3.1.4",
3
+ "version": "3.2.0",
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
+ "bin": {
7
+ "mcp-ssh-manager": "src/index.js"
8
+ },
6
9
  "type": "module",
7
10
  "scripts": {
8
11
  "start": "node src/index.js",
@@ -87,11 +87,13 @@ 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,
94
95
  platform: serverConfig.platform ? serverConfig.platform.toLowerCase() : undefined,
96
+ proxyJump: serverConfig.proxy_jump,
95
97
  source: 'toml'
96
98
  });
97
99
  }
@@ -134,11 +136,13 @@ export class ConfigLoader {
134
136
  user: env[`SSH_SERVER_${match[1]}_USER`],
135
137
  password: env[`SSH_SERVER_${match[1]}_PASSWORD`],
136
138
  keyPath: env[`SSH_SERVER_${match[1]}_KEYPATH`],
139
+ passphrase: env[`SSH_SERVER_${match[1]}_PASSPHRASE`],
137
140
  port: parseInt(env[`SSH_SERVER_${match[1]}_PORT`] || '22'),
138
141
  defaultDir: env[`SSH_SERVER_${match[1]}_DEFAULT_DIR`],
139
142
  sudoPassword: env[`SSH_SERVER_${match[1]}_SUDO_PASSWORD`],
140
143
  description: env[`SSH_SERVER_${match[1]}_DESCRIPTION`],
141
144
  platform: (env[`SSH_SERVER_${match[1]}_PLATFORM`] || '').toLowerCase() || undefined,
145
+ proxyJump: env[`SSH_SERVER_${match[1]}_PROXYJUMP`],
142
146
  source: 'env'
143
147
  };
144
148
 
@@ -186,10 +190,12 @@ export class ConfigLoader {
186
190
 
187
191
  if (server.password) serverConfig.password = server.password;
188
192
  if (server.keyPath) serverConfig.key_path = server.keyPath;
193
+ if (server.passphrase) serverConfig.passphrase = server.passphrase;
189
194
  if (server.defaultDir) serverConfig.default_dir = server.defaultDir;
190
195
  if (server.sudoPassword) serverConfig.sudo_password = server.sudoPassword;
191
196
  if (server.description) serverConfig.description = server.description;
192
197
  if (server.platform) serverConfig.platform = server.platform;
198
+ if (server.proxyJump) serverConfig.proxy_jump = server.proxyJump;
193
199
 
194
200
  config.ssh_servers[name] = serverConfig;
195
201
  }
@@ -212,11 +218,13 @@ export class ConfigLoader {
212
218
  lines.push(`SSH_SERVER_${upperName}_USER=${server.user}`);
213
219
  if (server.password) lines.push(`SSH_SERVER_${upperName}_PASSWORD="${server.password}"`);
214
220
  if (server.keyPath) lines.push(`SSH_SERVER_${upperName}_KEYPATH=${server.keyPath}`);
221
+ if (server.passphrase) lines.push(`SSH_SERVER_${upperName}_PASSPHRASE="${server.passphrase}"`);
215
222
  lines.push(`SSH_SERVER_${upperName}_PORT=${server.port || 22}`);
216
223
  if (server.defaultDir) lines.push(`SSH_SERVER_${upperName}_DEFAULT_DIR=${server.defaultDir}`);
217
224
  if (server.sudoPassword) lines.push(`SSH_SERVER_${upperName}_SUDO_PASSWORD="${server.sudoPassword}"`);
218
225
  if (server.description) lines.push(`SSH_SERVER_${upperName}_DESCRIPTION="${server.description}"`);
219
226
  if (server.platform) lines.push(`SSH_SERVER_${upperName}_PLATFORM=${server.platform}`);
227
+ if (server.proxyJump) lines.push(`SSH_SERVER_${upperName}_PROXYJUMP=${server.proxyJump}`);
220
228
  lines.push('');
221
229
  }
222
230
 
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
- dotenv.config({ path: path.join(__dirname, '..', '.env') });
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: path.join(__dirname, '..', '.env'),
180
+ envPath: envFilePath,
180
181
  tomlPath: process.env.SSH_CONFIG_PATH,
181
182
  preferToml: process.env.PREFER_TOML_CONFIG === 'true'
182
183
  }).then(loadedServers => {
@@ -224,6 +225,9 @@ const KEEPALIVE_INTERVAL = 5 * 60 * 1000;
224
225
  // Map to store keepalive intervals
225
226
  const keepaliveIntervals = new Map();
226
227
 
228
+ // Map to track proxy jump dependencies (target -> jump server)
229
+ const jumpDependencies = new Map();
230
+
227
231
  // Load server configuration (backward compatibility wrapper)
228
232
  function loadServerConfig() {
229
233
  // This function is kept for backward compatibility
@@ -338,6 +342,9 @@ function closeConnection(serverName) {
338
342
  // Remove timestamp
339
343
  connectionTimestamps.delete(normalizedName);
340
344
 
345
+ // Clean up jump dependency tracking
346
+ jumpDependencies.delete(normalizedName);
347
+
341
348
  logger.logConnection(serverName, 'closed');
342
349
  }
343
350
 
@@ -397,7 +404,45 @@ async function getConnection(serverName) {
397
404
  const ssh = new SSHManager(serverConfig);
398
405
 
399
406
  try {
400
- await ssh.connect();
407
+ if (serverConfig.proxyJump) {
408
+ const jumpServerName = serverConfig.proxyJump.toLowerCase();
409
+
410
+ // Validate jump server exists
411
+ if (!servers[jumpServerName]) {
412
+ throw new Error(
413
+ `Proxy jump server "${serverConfig.proxyJump}" not found. ` +
414
+ `Available servers: ${Object.keys(servers).join(', ')}`
415
+ );
416
+ }
417
+
418
+ // Detect circular proxy jumps
419
+ const visited = new Set([normalizedName]);
420
+ let current = jumpServerName;
421
+ while (current) {
422
+ if (visited.has(current)) {
423
+ throw new Error(`Circular proxy jump detected: ${[...visited, current].join(' -> ')}`);
424
+ }
425
+ visited.add(current);
426
+ current = servers[current]?.proxyJump?.toLowerCase() || null;
427
+ }
428
+
429
+ // Connect to jump server (recursive — handles chained jumps)
430
+ const jumpSSH = await getConnection(serverConfig.proxyJump);
431
+
432
+ // Create forwarded stream through the jump server
433
+ const stream = await jumpSSH.forwardOut(
434
+ '127.0.0.1', 0,
435
+ serverConfig.host, serverConfig.port || 22
436
+ );
437
+
438
+ // Connect target through the forwarded stream
439
+ await ssh.connect({ sock: stream });
440
+ jumpDependencies.set(normalizedName, jumpServerName);
441
+ ssh.jumpConnection = jumpSSH;
442
+ } else {
443
+ await ssh.connect();
444
+ }
445
+
401
446
  connections.set(normalizedName, ssh);
402
447
  connectionTimestamps.set(normalizedName, Date.now());
403
448
 
@@ -407,7 +452,8 @@ async function getConnection(serverName) {
407
452
  logger.logConnection(serverName, 'established', {
408
453
  host: serverConfig.host,
409
454
  port: serverConfig.port,
410
- method: serverConfig.password ? 'password' : 'key'
455
+ method: serverConfig.password ? 'password' : 'key',
456
+ proxyJump: serverConfig.proxyJump || null
411
457
  });
412
458
 
413
459
  // Execute post-connect hook
@@ -16,9 +16,10 @@ class SSHManager {
16
16
  this.cachedHomeDir = null;
17
17
  this.autoAcceptHostKey = config.autoAcceptHostKey || false;
18
18
  this.hostKeyVerification = config.hostKeyVerification !== false; // Default true
19
+ this.jumpConnection = null;
19
20
  }
20
21
 
21
- async connect() {
22
+ async connect(options = {}) {
22
23
  return new Promise((resolve, reject) => {
23
24
  this.client.on('ready', () => {
24
25
  this.connected = true;
@@ -98,15 +99,28 @@ class SSHManager {
98
99
  };
99
100
  }
100
101
 
102
+ // Use ssh-agent if available (handles passphrase-protected keys transparently)
103
+ if (process.env.SSH_AUTH_SOCK) {
104
+ connConfig.agent = process.env.SSH_AUTH_SOCK;
105
+ }
106
+
101
107
  // Add authentication (support both keyPath and keypath for compatibility)
102
108
  const keyPath = this.config.keyPath || this.config.keypath;
103
109
  if (keyPath) {
104
110
  const resolvedKeyPath = keyPath.replace('~', os.homedir());
105
111
  connConfig.privateKey = fs.readFileSync(resolvedKeyPath);
112
+ if (this.config.passphrase) {
113
+ connConfig.passphrase = this.config.passphrase;
114
+ }
106
115
  } else if (this.config.password) {
107
116
  connConfig.password = this.config.password;
108
117
  }
109
118
 
119
+ // Use provided stream for proxy jump connections
120
+ if (options.sock) {
121
+ connConfig.sock = options.sock;
122
+ }
123
+
110
124
  this.client.connect(connConfig);
111
125
  });
112
126
  }
@@ -444,6 +458,18 @@ class SSHManager {
444
458
  }
445
459
  }
446
460
 
461
+ async forwardOut(srcAddr, srcPort, dstAddr, dstPort) {
462
+ if (!this.connected) {
463
+ throw new Error('Not connected to SSH server');
464
+ }
465
+ return new Promise((resolve, reject) => {
466
+ this.client.forwardOut(srcAddr, srcPort, dstAddr, dstPort, (err, stream) => {
467
+ if (err) reject(err);
468
+ else resolve(stream);
469
+ });
470
+ });
471
+ }
472
+
447
473
  async ping() {
448
474
  try {
449
475
  const result = await this.execCommand('echo "ping"', { timeout: 5000 });
package/context-test.txt DELETED
@@ -1 +0,0 @@
1
- Server: production, Error: test-error