Skip to content

Commit d4dc2bd

Browse files
committed
feat: add SSH-compatible command-line interface and fix localhost connectivity
- Add SSH-compatible options (-l, -p, -o, -F, -Q, etc.) for drop-in replacement - Change cluster option from -c to -C to avoid conflicts with SSH options - Implement SSH mode detection for single-host connections (bssh user@host) - Auto-switch to interactive mode when no command provided (like SSH) - Fix authentication fallback to try default SSH keys (~/.ssh/id_rsa, etc.) - Skip SSH agent auto-detection to avoid failures with empty agents - Add -Q option for querying SSH capabilities (cipher, kex, etc.) - Update README and documentation for SSH compatibility - Create GitHub issues for remaining SSH features (PTY, port forwarding, jump hosts, config parsing)
1 parent 34e6abb commit d4dc2bd

5 files changed

Lines changed: 385 additions & 78 deletions

File tree

README.md

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
![CI](https://github.com/lablup/bssh/workflows/CI/badge.svg)
66
[![dependency status](https://deps.rs/repo/github/lablup/bssh/status.svg)](https://deps.rs/repo/github/lablup/bssh)
77

8-
A high-performance parallel SSH command execution tool for cluster management, built with Rust and `russh`.
8+
A high-performance SSH client with **SSH-compatible syntax** for both single-host and parallel cluster operations, built with Rust and `russh`.
99

1010
*Developed and maintained as part of the Backend.AI project.*
1111

1212
## Features
1313

14+
- **SSH Compatibility**: Drop-in replacement for SSH with compatible command-line syntax
1415
- **Parallel Execution**: Execute commands across multiple nodes simultaneously
1516
- **Cluster Management**: Define and manage node clusters via configuration files
1617
- **Progress Tracking**: Real-time progress indicators for each node
@@ -78,39 +79,57 @@ sudo cp target/release/bssh /usr/local/bin/
7879

7980
## Quick Start
8081

81-
### Execute command on multiple hosts
82+
### SSH-Compatible Mode (Single Host)
83+
```bash
84+
# Connect to a host (just like SSH!)
85+
bssh user@hostname
86+
87+
# Execute a command
88+
bssh user@hostname "uptime"
89+
90+
# With specific port and key
91+
bssh -p 2222 -i ~/.ssh/key.pem admin@server.com
92+
93+
# Using SSH options
94+
bssh -o StrictHostKeyChecking=no user@host
95+
96+
# Query SSH capabilities
97+
bssh -Q cipher
98+
```
99+
100+
### Multi-Server Mode (Cluster Operations)
82101
```bash
83102
# Using direct host specification
84103
bssh -H "user1@host1.com,user2@host2.com:2222" "uptime"
85104

86105
# Using cluster from config
87-
bssh -c production "df -h"
106+
bssh -C production "df -h"
88107

89108
# With custom SSH key
90-
bssh -c staging -i ~/.ssh/custom_key "systemctl status nginx"
109+
bssh -C staging -i ~/.ssh/custom_key "systemctl status nginx"
91110

92111
# Use SSH agent for authentication
93-
bssh --use-agent -c production "systemctl status nginx"
112+
bssh -A -C production "systemctl status nginx"
94113

95114
# Use password authentication (will prompt for password)
96115
bssh --password -H "user@host.com" "uptime"
97116

98117
# Use encrypted SSH key (will prompt for passphrase)
99-
bssh -i ~/.ssh/encrypted_key -c production "df -h"
118+
bssh -i ~/.ssh/encrypted_key -C production "df -h"
100119

101120
# Limit parallel connections
102-
bssh -c production --parallel 5 "apt update"
121+
bssh -C production --parallel 5 "apt update"
103122

104123
# Set command timeout (10 seconds)
105-
bssh -c production --timeout 10 "quick-check"
124+
bssh -C production --timeout 10 "quick-check"
106125

107126
# No timeout (unlimited execution time)
108-
bssh -c staging --timeout 0 "long-running-backup"
127+
bssh -C staging --timeout 0 "long-running-backup"
109128
```
110129

111130
### Test connectivity
112131
```bash
113-
bssh -c production ping
132+
bssh -C production ping
114133
```
115134

116135
### List configured clusters
@@ -187,7 +206,7 @@ bssh "nvidia-smi" # Check GPU status on all nodes
187206
bssh interactive # Opens interactive session with all Backend.AI nodes
188207

189208
# You can still override with explicit options if needed:
190-
bssh -c other-cluster "command" # Use a different cluster
209+
bssh -C other-cluster "command" # Use a different cluster
191210
bssh -H specific-host "command" # Use specific host
192211
```
193212

@@ -279,7 +298,7 @@ bssh "python train.py --distributed" # Run distributed training
279298

280299
### Run system updates
281300
```bash
282-
bssh -c production "sudo apt update && sudo apt upgrade -y"
301+
bssh -C production "sudo apt update && sudo apt upgrade -y"
283302
```
284303

285304
### Check disk usage
@@ -289,24 +308,24 @@ bssh -H "server1,server2,server3" "df -h | grep -E '^/dev/'"
289308

290309
### Restart services
291310
```bash
292-
bssh -c webservers "sudo systemctl restart nginx"
311+
bssh -C webservers "sudo systemctl restart nginx"
293312
```
294313

295314
### Collect logs
296315
```bash
297-
bssh -c production --output-dir ./logs "tail -n 100 /var/log/syslog"
316+
bssh -C production --output-dir ./logs "tail -n 100 /var/log/syslog"
298317
```
299318

300319
### Long-running commands with timeout
301320
```bash
302321
# Set 30 minute timeout for backup operations
303-
bssh -c production --timeout 1800 "backup-database.sh"
322+
bssh -C production --timeout 1800 "backup-database.sh"
304323

305324
# No timeout for data migration (may take hours)
306-
bssh -c production --timeout 0 "migrate-data.sh"
325+
bssh -C production --timeout 0 "migrate-data.sh"
307326

308327
# Quick health check with 5 second timeout
309-
bssh -c monitoring --timeout 5 "health-check.sh"
328+
bssh -C monitoring --timeout 5 "health-check.sh"
310329
```
311330

312331
### Interactive Mode
@@ -315,16 +334,16 @@ Start an interactive shell session on cluster nodes:
315334

316335
```bash
317336
# Interactive session on all nodes (multiplex mode - default)
318-
bssh -c production interactive
337+
bssh -C production interactive
319338

320339
# Interactive session on a single node
321-
bssh -c production interactive --single-node
340+
bssh -C production interactive --single-node
322341

323342
# Custom prompt format
324343
bssh -H server1,server2 interactive --prompt-format "{user}@{host}> "
325344

326345
# Set initial working directory
327-
bssh -c staging interactive --work-dir /var/www
346+
bssh -C staging interactive --work-dir /var/www
328347
```
329348

330349
#### Interactive Mode Configuration
@@ -410,7 +429,7 @@ For large clusters (>10 nodes), the prompt uses a compact format:
410429
#### Example Interactive Session
411430

412431
```bash
413-
$ bssh -c production interactive
432+
$ bssh -C production interactive
414433
415434
Connected to 3 nodes
416435
[● ● ●] bssh> !status
@@ -480,13 +499,13 @@ Each output file includes metadata headers:
480499
### Example Usage
481500
```bash
482501
# Save outputs to timestamped directory
483-
bssh -c production --output-dir ./results/$(date +%Y%m%d) "ps aux | head -10"
502+
bssh -C production --output-dir ./results/$(date +%Y%m%d) "ps aux | head -10"
484503
485504
# Collect system information
486-
bssh -c all-servers --output-dir ./system-info "uname -a; df -h; free -m"
505+
bssh -C all-servers --output-dir ./system-info "uname -a; df -h; free -m"
487506
488507
# Debug failed services
489-
bssh -c webservers --output-dir ./debug "systemctl status nginx"
508+
bssh -C webservers --output-dir ./debug "systemctl status nginx"
490509
```
491510

492511
## Development

0 commit comments

Comments
 (0)