Commit 167eaaf
authored
feat: Add SSH jump host (-J) infrastructure and CLI integration (#30)
* feat: Add SSH jump host (-J) infrastructure and CLI integration
This commit implements the foundation for SSH jump host support with OpenSSH-compatible -J syntax:
- **Jump Host Parser**: Robust parsing of OpenSSH ProxyJump format (`user@host:port,user2@host2:port2`)
- Supports single and multiple jump hosts
- IPv6 address handling with bracket notation
- Comprehensive input validation and error handling
- **CLI Integration**: Full -J option support with jump host specification parsing
- OpenSSH-compatible command-line syntax
- Integration with existing command structure (exec, ping, upload, download)
- Informative logging when jump hosts are detected
- **Connection Management**: Infrastructure for jump host connection chains
- JumpHostChain for managing multi-hop connections
- Connection health monitoring and statistics
- Error handling with jump context information
- **SSH Client Extensions**: Enhanced tokio_client with jump host capabilities
- Public session access for direct-tcpip channel operations
- Infrastructure for channel-based SSH connections
- ✅ Jump host specification parsing with comprehensive tests
- ✅ CLI integration with -J option working
- ✅ Connection chain management structure
- ✅ All existing tests passing (99 tests)
- 🚧 Actual SSH tunneling through jump hosts (requires deeper russh integration)
- 17 new unit tests for jump host parsing and chain management
- Comprehensive error handling tests for malformed specifications
- IPv6 and edge case handling validated
```bash
bssh -J jump@bastion.example.com -H target@internal.server "uptime"
bssh -J "jump1@bastion1,jump2@bastion2" -C production "df -h"
```
The foundation is now in place for full jump host functionality. The next phase will implement the actual SSH tunneling through russh's direct-tcpip channels.
feat: Complete SSH jump host (ProxyJump) implementation
- Full SSH tunneling through jump hosts using russh direct-tcpip channels
- OpenSSH ProxyJump syntax compatibility with -J/--jump-host option
- Multi-hop connection chaining through intermediate jump hosts
- Comprehensive authentication support (SSH agent, key files, passwords)
- Connection timeout and error handling for all tunnel stages
- CLI integration with existing cluster and single-host operations
- Code refactoring to reduce function parameter counts via config structs
- Documentation updates in README.md with usage examples
Enables secure access to internal hosts through bastion servers with
syntax like: bssh -J jump@bastion.example.com user@internal-host
fix(security): Fix host key verification bypass and sensitive data handling - Priority: CRITICAL
- Always verify host keys for intermediate jump hosts to prevent MITM attacks
- Use Zeroizing wrapper for SSH key file contents to clear from memory
- Pass strict mode configuration through the entire jump chain
- Ensure all sensitive data (passwords, passphrases, keys) are properly zeroed
fix(security): Add rate limiting for connection attempts - Priority: HIGH
- Implement token bucket rate limiter to prevent DoS attacks
- Default limits: 10 connection burst, 2 connections/second sustained
- Per-host rate limiting with automatic cleanup of old buckets
- Configurable rate limits via with_rate_limit() method
- Apply rate limiting to all connection attempts (direct, jump hosts, destination)
fix(perf): Fix connection pool resource leak - Priority: HIGH
- Add automatic cleanup of stale connections (idle > 5 min, age > 30 min)
- Clean up connections periodically when pool size exceeds threshold
- Add connection age and idle time tracking
- Implement proper Drop trait logging for debugging
- Add methods to monitor active connection count
fix(security): Add input sanitization for command execution - Priority: HIGH
- Add comprehensive input sanitization module with validation functions
- Sanitize commands to detect injection patterns and dangerous constructs
- Validate and sanitize hostnames to prevent DNS/SSH injection
- Validate and sanitize usernames with proper character restrictions
- Apply sanitization to all command execution and jump host parsing
- Add CommandValidationFailed error variant for proper error handling
- Add comprehensive test coverage for sanitization functions
fix: remove vendor files
update: .gitignore
* update: Cargo.lock
* fix: handle IPv6 addresses in jump hosts and stabilize environment variable tests1 parent f877d21 commit 167eaaf
20 files changed
Lines changed: 2636 additions & 139 deletions
File tree
- src
- commands
- jump
- ssh
- ssh_config/integration_tests
- tokio_client
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
101 | 120 | | |
102 | 121 | | |
103 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
85 | 92 | | |
86 | 93 | | |
87 | 94 | | |
| |||
160 | 167 | | |
161 | 168 | | |
162 | 169 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | 170 | | |
172 | 171 | | |
173 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | | - | |
| 53 | + | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
720 | 720 | | |
721 | 721 | | |
722 | 722 | | |
723 | | - | |
724 | | - | |
725 | | - | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
726 | 729 | | |
727 | 730 | | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
728 | 739 | | |
729 | 740 | | |
730 | 741 | | |
| |||
0 commit comments