A powerful Python tool for executing commands on multiple SSH servers concurrently with advanced features for network operations management.
- Parallel SSH Execution: Execute commands on multiple servers simultaneously with configurable connection limits
- IP Validation & Whitelisting: Security features to restrict access to authorized IP addresses only
- Dual Server Groups: Support for primary and secondary server groups with different user credentials
- Variable Substitution: Dynamic variable replacement (
$CLIENT_NUM) in commands and usernames - Configuration Management: Flexible configuration via files in multiple locations
- IP Range Support: Expand IP ranges (e.g., "1-5", "150-154") automatically
- Enhanced Security: Strict SSH options and secure connection handling
- Signal Handling: Clean shutdown on interruption (Ctrl+C)
- Timeout Management: Both per-connection and global timeout protection
- Error Handling: Comprehensive error reporting and formatted output
- Multiple Installation Modes: System-wide (
/usr/local/bin) or user-only (~/.local/bin) - Update Capability: Version checking and seamless updates
- Uninstall Support: Clean removal with optional configuration preservation
- Backup Protection: Automatic backup of existing installations
- Version Tracking: Proper version management and status reporting
python3 install.py install --usersudo python3 install.py install --systempython3 install.py install [--user|--system] [--force]- Install the toolpython3 install.py update [--user|--system]- Update existing installationpython3 install.py uninstall [--user|--system]- Remove installationpython3 install.py status- Show installation status
ssh-operations-hub --ips 1 2 3 --primary-user root --command "uptime"ssh-operations-hub \
--primary-ips 1 2 3 --primary-user root \
--secondary-ips 10 11 12 --secondary-user admin \
--command "systemctl status nginx"ssh-operations-hub --ip-prefix 192.168.1 --ips 10 20 30 --primary-user admin --command "df -h"ssh-operations-hub --ips 1 2 3 --primary-user "user\$CLIENT_NUM" --command "echo 'I am client \$CLIENT_NUM'"--primary-ips,--ips: List of IP suffixes for primary group--secondary-ips: List of IP suffixes for secondary group--primary-user: Username for primary group (default: root)--secondary-user: Username for secondary group (default: admin)--command: Command to execute on all clients (required)--ip-prefix: Custom IP prefix (e.g., 192.168.1)
$HOME/.config/ssh-operations-hub/defaults.json(User config)<script_dir>/config/defaults.json(Development)/etc/ssh-operations-hub/defaults.json(System config)
{
"ip_prefix": "10.200.142",
"allowed_ips": ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "15", "17", "20", "21", "22", "23", "24", "25", "150-154"]
}- Individual IPs:
["1", "2", "3"] - Ranges:
["1-5"](expands to 1 2 3 4 5) - Mixed:
["1", "2", "5-7", "10"](expands to 1 2 5 6 7 10)
- Better Parallel Control: Uses
concurrent.futures.ThreadPoolExecutorfor optimal thread management - Efficient IP Validation: Uses Python's built-in data structures for faster lookups
- Improved Error Handling: Exception-based error handling with proper cleanup
- Better Resource Management: Automatic cleanup of connections and threads
- Enhanced Configuration: More robust configuration parsing and validation
- IP Whitelisting: Only allowed IP suffixes can be targeted
- SSH Security Options:
BatchMode=yes(no interactive prompts)ConnectTimeout=5(connection timeout)StrictHostKeyChecking=accept-new(accept new host keys)ControlMaster=no(no connection sharing)
- Input Validation: Comprehensive validation of all inputs
- Configuration Protection: Secure file permissions for configuration files
- Main Class:
SSHOperationsHub- Core functionality - Installer Class:
SSHOperationsHubInstaller- Installation management - Thread Pool: Configurable parallel execution (default: 10 concurrent connections)
- Signal Handling: Clean shutdown on SIGINT/SIGTERM
- Logging: Structured logging with proper formatting
The Python version has been modernized with a new, more intuitive interface:
- π Modern CLI Arguments: Updated from short flags (
-ip,-cmd,-suser) to descriptive long options (--ips,--command,--secondary-user) - π JSON Configuration: Migrated from bash-style config to standard JSON format
- ποΈ Removed Legacy: Old bash scripts have been removed for cleaner codebase
- π§Ή Enhanced Uninstaller: Automatically removes old bash installations
-
Update CLI Commands: Replace old arguments:
-ipβ--ipsor--primary-ips-cmdβ--command-user/-puserβ--primary-user-suserβ--secondary-user-primaryβ--primary-ips-secondaryβ--secondary-ips
-
Convert Configuration: Update config files from bash format to JSON:
# Old format (defaults.conf) IP_PREFIX="10.200.142" ALLOWED_IPS="1 2 3 150-154"
// New format (defaults.json) { "ip_prefix": "10.200.142", "allowed_ips": ["1", "2", "3", "150-154"] }
-
Uninstall Old Version: The uninstaller will automatically remove old bash files
- β Same IP validation and whitelisting rules
- β
Same variable substitution (
$CLIENT_NUM) - β Same dual server group functionality
- β Same parallel execution capabilities
- β Same output formatting and error messages
Run the test suite:
python3 test_ssh_operations_hub.py
python3 test_installer.py- Python 3.6 or later
- SSH client (
sshcommand) - Standard Linux/Unix environment
- Complete rewrite in Python for better performance and maintainability
- Enhanced installer with update/uninstall capabilities
- Improved parallel processing with ThreadPoolExecutor
- Comprehensive test coverage
- Better error handling and logging
- Full backward compatibility with v1.x configuration and CLI
- Original Bash implementation
- Basic installation support
- Parallel SSH execution
- Configuration file support
For complete documentation and support:
- Documentation: https://umd-uroc.github.io/docs/SSH Operations Hub
- Issues: Use the GitHub issue tracker
- Configuration: Check the config file examples in the
config/directory
See LICENSE file for details.