Skip to content

feat: add SSH-compatible command-line interface and fix localhost connectivity#25

Merged
inureyes merged 4 commits into
mainfrom
feature/ssh-compatibility
Aug 27, 2025
Merged

feat: add SSH-compatible command-line interface and fix localhost connectivity#25
inureyes merged 4 commits into
mainfrom
feature/ssh-compatibility

Conversation

@inureyes
Copy link
Copy Markdown
Member

Summary

This PR adds SSH-compatible command-line interface to bssh, enabling it to work as a drop-in replacement for the standard SSH client while maintaining its powerful multi-server capabilities.

Key Changes

SSH Compatibility Mode

  • Added support for SSH-style command syntax: bssh user@host [command]
  • Implemented SSH-compatible options (-l, -p, -o, -F, -Q, etc.)
  • Auto-detection of single-host vs multi-server mode
  • Parse SSH URIs: ssh://user@host:port

Command-Line Options

  • Changed cluster option from -c to -C to avoid conflicts with SSH
  • Added -l for login username (SSH-compatible)
  • Added -p for port specification (moved parallel to --parallel only)
  • Added -o for SSH options (e.g., -o StrictHostKeyChecking=no)
  • Added -F for SSH config file specification
  • Added -Q for querying SSH capabilities (cipher, kex, mac, etc.)
  • Added -t/-T for TTY control
  • Added -4/-6 for IP version forcing

Authentication & Connection Fixes

  • Fixed localhost connectivity issue: bssh localhost now works like ssh localhost
  • Improved authentication fallback to try default SSH keys (~/.ssh/id_rsa, id_ed25519, etc.)
  • Skip SSH agent auto-detection to avoid failures with empty agents
  • Only use SSH agent when explicitly requested with -A flag

Interactive Mode

  • Auto-switch to interactive mode when no command is provided (like SSH)
  • Single-host SSH connections now properly start interactive sessions
  • Fixed issue where bssh tried to execute "bash || sh" as a command

Usage Examples

# SSH-compatible single host mode
bssh user@hostname                    # Interactive shell
bssh user@hostname "uptime"           # Execute command  
bssh -p 2222 -i ~/.ssh/key user@host  # Custom port and key
bssh -o StrictHostKeyChecking=no host # SSH options

# Multi-server mode (existing functionality)
bssh -C production "uptime"           # Cluster execution
bssh -H "host1,host2,host3" "df -h"   # Multiple hosts

Testing

All the following now work correctly:

  • bssh localhost - Interactive session without specifying key
  • bssh localhost whoami - Command execution
  • bssh user@host - SSH-style connection
  • bssh -i ~/.ssh/key host - Explicit key specification
  • bssh -Q cipher - Query SSH capabilities

Related Issues

Created follow-up issues for remaining SSH features:

Breaking Changes

  • Cluster option changed from -c to -C (uppercase)
  • Parallel option -p is now --parallel only (to support SSH port option)

Migration Guide

For existing users:

  • Replace -c cluster with -C cluster in scripts
  • Replace -p N with --parallel N for parallelism control

…nectivity

- 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)
@inureyes inureyes added type:enhancement New feature or request add labels Aug 27, 2025
@inureyes inureyes self-assigned this Aug 27, 2025
- Add SSH-compatible options section with all new options (-l, -p, -o, -F, -Q, etc.)
- Update synopsis to reflect SSH-style usage: bssh [destination] [command]
- Change cluster option from -c to -C in all examples
- Change parallel option from -p to --parallel in examples
- Add SSH compatibility mode examples
- Add breaking changes notice for existing users
- Update description to emphasize drop-in SSH replacement capability
Fixed last instance of old cluster option in ping command example
- Changed -c to -C for cluster option in download and upload tests
- Changed -p to --parallel for parallel option in both test files
- Tests now pass with the new SSH-compatible CLI structure
@inureyes inureyes merged commit ea293d7 into main Aug 27, 2025
3 checks passed
inureyes added a commit that referenced this pull request Aug 27, 2025
Resolve conflicts by keeping SSH compatibility features from main:
- SSH-compatible command-line interface (#25)
- Help message when no arguments provided (#20)
- Parallel config support fix (#18)

All functionality from both branches preserved including:
- SSH mode with interactive shell support
- Multi-server mode with parallel execution
- Proper argument parsing for SSH compatibility
- Configuration-based parallel limits
@inureyes inureyes added priority:high High priority issue status:done Completed feature labels Sep 9, 2025
@inureyes inureyes removed the add label Oct 27, 2025
@inureyes inureyes deleted the feature/ssh-compatibility branch October 30, 2025 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:high High priority issue status:done Completed type:enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant