DevOps / Scripts bash Intermediate

SSH Key Distributor

Push your public key to multiple remote servers in one loop.

bash
#!/bin/bash
SERVERS=(user@192.168.1.10 user@192.168.1.11 user@192.168.1.12)
for host in "${SERVERS[@]}"; do
  ssh-copy-id -i ~/.ssh/id_ed25519.pub "$host" && echo OK: $host
done

Prerequisites

  • ssh-copy-id
  • SSH key pair

Pro Tips

  • → Generate key with ssh-keygen -t ed25519.

Was this module useful?

Share your experience — it helps the team improve.

Leave Feedback

Commercial Licensing

Acquire a production access token or template license for enterprise deployment.

Module Info

Language
bash
Level
Intermediate
Read time
2 min
Published
Apr 2024
License
Commercial License

Newsletter

New modules every week, directly to your inbox.