A command-line tool to execute commands on multiple remote hosts
Project description
Ananta (formerly Hydra)
Ananta is a powerful command-line tool designed to simplify simultaneous SSH command execution across multiple remote hosts. It enhances workflows, automates repetitive tasks, and improves efficiency for system administrators and developers managing distributed systems.
Namesake
Ananta draws inspiration from Ananta Shesha or Ananta Nagaraja (อนันตนาคราช), the many-headed serpentine demigod from Hindu mythology deeply rooted in Thai culture.
Initially, this project was named Hydra, referencing the many-headed serpent in Greek mythology. However, due to the abundance of projects named Hydra or hydra-* on PyPI (e.g., the previous project at https://pypi.org/project/hydra-ssh/), it was renamed to Ananta. The commands you now use are ananta, which is shorter, more distinctive, and easier to remember than hydra-ssh.
Features
- Concurrent execution of commands across multiple remote hosts
- Flexible host list configuration in TOML or CSV format
- SSH authentication with public key support
- Lightweight and user-friendly command-line interface
- Color-coded output for easy host differentiation
- Option to separate host outputs for clarity
- Support for cursor control codes for specific layouts (e.g.,
fastfetch,neofetch)
Installation
System Requirements
- Python 3.10 or higher
pippackage manager- Required dependencies:
asyncssh,argparse,asyncio - Optional:
uvloop(Unix-based systems) orwinloop(Windows) for enhanced performance - For TOML host files on Python 3.10:
tomli(automatically installed)
Installing via pip
Install Ananta using pip:
pip install ananta --user
Install Ananta with uvloop or winloop for speed enhancement:
pip install ananta[speed] --user
Note: Ensure Python 3.10 or higher is installed. For TOML host files, Python 3.10 requires tomli, while Python 3.11 and above use the built-in tomllib. If you previously used hydra-ssh, update to pip install ananta to get the latest version.
Usage
Hosts File Format
Ananta supports host files in TOML or CSV format, allowing flexible configuration of remote hosts. Below are the structures for each format.
Note: The TOML format is recommended for its clarity and ease of use. Any hosts file without .toml extension will be treated as a CSV file.
TOML Host File
Create a TOML file with a [default] section (optional) and host sections. Example:
[default]
port = 22
username = "user"
key_path = "#"
tags = ["common"]
[host-1]
ip = "10.0.0.1"
port = 2222
key_path = "/home/user/.ssh/id_ed25519"
[host-2]
ip = "10.0.0.2"
tags = ["web"]
[host-3]
ip = "10.0.0.3"
tags = ["arch", "web"]
["host-4"]
ip = "10.0.0.4"
tags = ["ubuntu", "db"]
- [default] Section:
- Optional section to set default values for
port,username,key_path, andtags. key_pathcan be#to use the default SSH key which can be specified via-kor common keys in~/.ssh/.- Fields not specified in a host section will use these defaults (except
ip, which is required). tags: Default tags applied to all hosts, appended to host-specific tags.
- Optional section to set default values for
- Host Sections:
- Each section (e.g.,
[host-1]) defines a host with the following fields to override defaults:ip: Required IP address or resolvable hostnameport: SSH portusername: SSH usernamekey_path: Path to SSH private keytags: Optional list of tags (e.g.,["web", "prod"])
- Each section (e.g.,
- Tags:
- Tags from
[default]are appended to tags specified in each host section. - For example, if
default.tags = ["common"]andhost-3.tags = ["arch", "web"],host-3will have tags["common", "arch", "web"]. - Use the
-toption to filter hosts by tags (e.g.,-t common,webmatches hosts with any of these tags).
- Tags from
- Note: TOML parsing requires
tomlion Python 3.10 (included in Ananta's dependencies) ortomllibon Python 3.11 and above.
CSV Host File
Create a CSV file with the following structure:
#alias,ip,port,username,key_path,tags(optional - colon separated)
host-1,10.0.0.1,2222,user,/home/user/.ssh/id_ed25519
host-2,10.0.0.2,22,user,#,web
host-3,10.0.0.3,22,user,#,arch:web
host-4,10.0.0.4,22,user,#,ubuntu:db
- Lines starting with
#are ignored. - Fields:
alias: Unique name for the hostip: IP address or resolvable hostnameport: SSH port numberusername: SSH usernamekey_path: Path to SSH private key, or#to use the default key (via-kor common keys in~/.ssh/)tags: Optional tags, separated by colons (e.g.,web:db)
- Tags: Used for filtering hosts with the
-toption (e.g.,-t web,db).
Running Commands
Run commands on remote hosts with:
ananta <options> [hosts file] [command]
Examples:
# Run 'uptime' on all hosts in a CSV hosts file
$ ananta hosts.csv uptime
# Run 'sensors' with separate output on all hosts in a CSV hosts file
$ ananta -s host.csv sensors
# Run 'fastfetch' with cursor control enabled and separate output on all hosts in a TOML hosts file
$ ananta -cs hosts.toml fastfetch
# Filter hosts by tags 'web' or 'db' (CSV hosts file)
$ ananta -t web,db hosts.csv uptime
# Filter hosts by tags 'common' or 'web' (TOML hosts file, includes default tags)
$ ananta -t common,web hosts.toml uptime
# Update Arch Linux hosts (TOML hosts file)
$ ananta -t arch hosts.toml sudo pacman -Syu --noconfirm
Options
Single-letter options are case-insensitive.
-n, --no-color: Disable colorized output-s, --separate-output: Display output from each host separately-t, --host-tags: Filter hosts by tag(s), comma-separated (e.g.,web,db)-w, --terminal-width: Manually set terminal width-e, --allow-empty-line: Permit printing of empty lines-c, --allow-cursor-control: Enable cursor control codes (e.g., forfastfetchorneofetch)-v, --version: Display the Ananta version-k, --default-key: Specify the default SSH private key path
Demo
License
The MIT License (MIT)
Copyright (c) 2023-2025 cwt(at)bashell(dot)com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ananta-1.2.1.tar.gz.
File metadata
- Download URL: ananta-1.2.1.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.13.3 Linux/6.14.6-300.fc42.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cee41631e29092a510e586494758f6c99333404d7cfd3b395cc66f23d02959c4
|
|
| MD5 |
38c4895c05a730a75ca4ce71c78f7096
|
|
| BLAKE2b-256 |
e18f3108eb3df6febcac03ae9d2608193463c7e0571c79a87cc3a28564eb8b0c
|
File details
Details for the file ananta-1.2.1-py3-none-any.whl.
File metadata
- Download URL: ananta-1.2.1-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.13.3 Linux/6.14.6-300.fc42.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85db5ce0d2f85621636152938d3e5a88c77c67515b238700f9b32c8a2528dd3e
|
|
| MD5 |
97fb9f4ab126f442cbdc4b1e5f4dd2a9
|
|
| BLAKE2b-256 |
c5509a53093a3d813142eb87bdbceb5ff5a37d40a84190882162b4f37e19cdad
|