Loop SSH Across Hosts
Run the same command on a list of hosts with -o BatchMode for key-only auth.
Author:
chris
// Language: Bash
#!/usr/bin/env bash
set -euo pipefail
hosts=(web01 web02 web03 db01)
for h in "${hosts[@]}"; do
printf '=== %s ===\n' "$h"
ssh -o BatchMode=yes -o ConnectTimeout=5 "$h" 'uptime'
done