24 lines
513 B
Bash
24 lines
513 B
Bash
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
: "${TARGET_HOSTS:?TARGET_HOSTS is not configured}"
|
|
: "${SSH_USER:?SSH_USER is not configured}"
|
|
|
|
SSH_KEY="$HOME/.ssh/ansible_ed25519"
|
|
|
|
if [[ ! -r "$SSH_KEY" ]]; then
|
|
echo "ERROR: SSH key not found: $SSH_KEY"
|
|
exit 1
|
|
fi
|
|
|
|
for host in $TARGET_HOSTS; do
|
|
echo "Connecting to $host..."
|
|
|
|
ssh \
|
|
-i "$SSH_KEY" \
|
|
-o IdentitiesOnly=yes \
|
|
-o BatchMode=yes \
|
|
-o StrictHostKeyChecking=accept-new \
|
|
"$SSH_USER@$host" \
|
|
'hostname'
|
|
done |