Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bssh"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
authors = ["Jeongkyu Shin"]
description = "Parallel SSH command execution tool for cluster management"
Expand All @@ -22,6 +22,7 @@ indicatif = "0.18"
rpassword = "7"
directories = "5"
dirs = "6.0"
chrono = "0.4"

[dev-dependencies]
tempfile = "3"
Expand Down
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ A high-performance parallel SSH command execution tool for cluster management, b
- **Flexible Authentication**: Support for SSH keys and SSH agent
- **Host Key Verification**: Secure host key checking with known_hosts support
- **Cross-Platform**: Works on Linux and macOS
- **Output Management**: Save command outputs to files per node with detailed logging

## Installation

Expand Down Expand Up @@ -158,6 +159,52 @@ bssh -c webservers "sudo systemctl restart nginx"
bssh -c production --output-dir ./logs "tail -n 100 /var/log/syslog"
```

## Output File Management

When using the `--output-dir` option, bssh saves command outputs to structured files:

### File Structure
```
output-dir/
├── hostname1_20250821_143022.stdout # Standard output
├── hostname1_20250821_143022.stderr # Standard error (if any)
├── hostname2_20250821_143022.stdout # Per-node outputs
├── hostname2_20250821_143022.error # Connection/execution errors
├── hostname3_20250821_143022.empty # Marker for no output
└── summary_20250821_143022.txt # Overall execution summary
```

### File Types
- **`.stdout`**: Contains standard output from successful commands
- **`.stderr`**: Contains standard error output (created only if stderr is not empty)
- **`.error`**: Contains error messages for failed connections or executions
- **`.empty`**: Marker file when command produces no output
- **`summary_*.txt`**: Overall execution summary with success/failure counts

### File Headers
Each output file includes metadata headers:
```
# Command: df -h
# Host: server1.example.com
# User: admin
# Exit Status: 0
# Timestamp: 20250821_143022

[actual command output follows]
```

### Example Usage
```bash
# Save outputs to timestamped directory
bssh -c production --output-dir ./results/$(date +%Y%m%d) "ps aux | head -10"

# Collect system information
bssh -c all-servers --output-dir ./system-info "uname -a; df -h; free -m"

# Debug failed services
bssh -c webservers --output-dir ./debug "systemctl status nginx"
```

## Development

### Building
Expand Down
43 changes: 41 additions & 2 deletions docs/man/bssh.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" Manpage for bssh
.\" Contact the maintainers to correct errors or typos.
.TH BSSH 1 "August 21, 2025" "v0.2.0" "bssh Manual"
.TH BSSH 1 "August 21, 2025" "v0.3.0" "bssh Manual"

.SH NAME
bssh \- Backend.AI SSH - Parallel command execution across cluster nodes
Expand Down Expand Up @@ -50,7 +50,8 @@ Maximum parallel connections (default: 10)

.TP
.BR \-\-output\-dir " " \fIOUTPUT_DIR\fR
Output directory for command results
Output directory for command results. When specified, saves command outputs
to separate files for each node with stdout, stderr, and execution summary

.TP
.BR \-v ", " \-\-verbose
Expand Down Expand Up @@ -180,6 +181,17 @@ Use SSH agent for authentication:
.TP
Save output to files:
.B bssh --output-dir ./results -c production "ps aux"
.RS
Creates timestamped files per node:
.br
- hostname_TIMESTAMP.stdout (standard output)
.br
- hostname_TIMESTAMP.stderr (error output)
.br
- hostname_TIMESTAMP.error (connection errors)
.br
- summary_TIMESTAMP.txt (execution summary)
.RE

.SH EXIT STATUS
.TP
Expand All @@ -190,6 +202,33 @@ Success - all commands executed successfully on all nodes
.B 1
Failure - one or more commands failed or connection errors occurred

.SH OUTPUT FILES
When using the
.B --output-dir
option, bssh creates the following files:

.TP
.I hostname_YYYYMMDD_HHMMSS.stdout
Standard output from successful command execution

.TP
.I hostname_YYYYMMDD_HHMMSS.stderr
Standard error output (created only if stderr is not empty)

.TP
.I hostname_YYYYMMDD_HHMMSS.error
Error messages for failed connections or command execution

.TP
.I hostname_YYYYMMDD_HHMMSS.empty
Marker file when command produces no output

.TP
.I summary_YYYYMMDD_HHMMSS.txt
Overall execution summary with success/failure counts for all nodes

Each output file includes metadata headers with command, host, user, exit status, and timestamp information.

.SH FILES
.TP
.I ~/.bssh/config.yaml
Expand Down
Loading
Loading