OPENSSH WITH SWAMP
Swamp automates OpenSSH by treating a set of SSH hosts as a single behavior. You declare the hosts once, with their addresses, tags and connection settings, and then run methods against any subset of them. Each host records its own outcome as data. A failed host is therefore visible by name, and workflows can gate on what happened on each machine.
Get started
curl -fsSL https://swamp-club.com/install.sh | sh swamp repo init swamp extension pull @swamp/ssh swamp extension pull @keeb/ssh swamp extension pull @hivemq/ssh/authorized-keysThe fleet extension
The @swamp/ssh extension provides most of this work. Its behavior type keeps
the fleet in the hosts global argument and the fleet-wide connection defaults
in transport: user, port, identity, proxy jump, authentication mode and
ControlMaster settings. Any host can override those defaults. Hosts can connect
over OpenSSH or over Tailscale SSH, and one fleet can mix the two.
The type's methods cover the usual remote operations. exec and script run
commands, copy moves files with scp or rsync, and forward opens port
forwards. open, check and close manage ControlMaster sockets, and
collect-host-public-key reads each host's SSH host key and its SHA256
fingerprint. The resolve method reports which hosts a selector matches without
connecting to any of them. A selector can be a host name, a tag, a list of
names, all, or a CEL expression with the cel: prefix.
Every host that a method touches writes a run-<method>-<host> resource tagged
with the fleet, host, method and exit code. exec and script accept
okExitCodes, so a guard command such as test -f can exit 1 and still count
as an answer. The guide
Run a guarded command across tagged SSH hosts
shows this pattern.
Record SSH host key fingerprints for a fleet
shows how to store each host's key as data.
Other SSH extensions
Several other extensions cover narrower jobs:
@hivemq/ssh/authorized-keysdeclares which public keys must be present or absent on every host, then audits, verifies, adds, strips or sealsauthorized_keysfiles to match.@hivemq/hetzner/ssh/authorized-keysaudits and verifiesauthorized_keyson Hetzner servers, with optional password authentication throughsshpass.@hivemq/ssh/keygengenerates an ed25519 key pair and stores the private key in a Swamp vault.@hivemq/ssh/rotate-configrecords the vault key names that a rotation workflow reads.@keeb/sshruns commands on a single host, uploads files to it and waits for it to become reachable.@evrardjp/ssh-camanages an OpenSSH certificate authority: certificates, trust lines and key revocation lists.
The guide
Enforce authorized_keys across hosts with Swamp
uses @hivemq/ssh/authorized-keys. The
extensions reference lists every
type, global argument and method.
Where to start
If you have not used these extensions before, the getting started tutorial walks through declaring a three-host fleet, resolving selectors against it and running a command on the matched hosts. Understanding SSH automation in Swamp covers why fleets are modelled this way, how credentials stay in vaults, and how to choose between the extensions.
OpenSSH documentation
Getting started with SSH fleets in Swamp
Pull the @swamp/ssh extension, declare a three-host fleet as a behavior, validate it, and resolve host selectors by tag and CEL before running a remote command.
Tutorials →Run a guarded command across tagged SSH hosts
Resolve a tag selector to fleet members, then run a test command on each host with @swamp/ssh exec and okExitCodes so exit 1 is recorded as a valid answer.
How-to Guides →Enforce authorized_keys across hosts with Swamp
Declare which SSH public keys must be present or absent on every host, verify compliance with @hivemq/ssh/authorized-keys, then add and strip keys to match.
How-to Guides →Record SSH host key fingerprints for a fleet
Read each fleet host's ed25519 public key with the @swamp/ssh collect-host-public-key method and store its algorithm and SHA256 fingerprint as Swamp data.
How-to Guides →OpenSSH extensions
Every Swamp extension for OpenSSH: behavior types, global arguments, methods, vault configuration and the data each one writes, read from the registry.
Reference →Understanding SSH automation in Swamp
How Swamp represents an SSH fleet as one behavior, records each host's outcome as data, keeps credentials in vaults, and compares the available SSH extensions.
Explanation →