| 1 | #!/bin/bash |
| 2 | |
| 3 | # Exit immediately if a command exits with a non-zero status |
| 4 | set -e |
| 5 | |
| 6 | # Configuration |
| 7 | REMOTE_USER="root" |
| 8 | REMOTE_DIR="/etc/ssl/certs" |
| 9 | CERT_FILE="/path/to/local/cert.crt" |
| 10 | KEY_FILE="/path/to/local/cert.key" |
| 11 | |
| 12 | # List of remote hosts (IP addresses or hostnames) |
| 13 | HOSTS=( |
| 14 | "192.168.1.10" |
| 15 | "192.168.1.11" |
| 16 | "192.168.1.12" |
| 17 | ) |
| 18 | |
| 19 | for HOST in "${HOSTS[@]}"; do |
| 20 | echo "Processing $HOST..." |
| 21 | |
| 22 | # Copy certificate and key files |
| 23 | scp "$CERT_FILE" "$KEY_FILE" "${REMOTE_USER}@${HOST}:${REMOTE_DIR}/" |
| 24 | |
| 25 | # Optional: Restart service on remote host (e.g., Nginx, Apache) |
| 26 | #ssh "${REMOTE_USER}@${HOST}" "systemctl restart nginx" |
| 27 | |
| 28 | echo "Successfully updated $HOST" |
| 29 | done |
| 30 | |
| 31 | echo "All certificates pushed successfully." |
| 32 |
jblu / push-certs.sh
Last active 1 month ago