jblu

jblu / push-certs.sh

Last active 1 month ago

Like 0
push-certs.sh Raw
1#!/bin/bash
2
3# Exit immediately if a command exits with a non-zero status
4set -e
5
6# Configuration
7REMOTE_USER="root"
8REMOTE_DIR="/etc/ssl/certs"
9CERT_FILE="/path/to/local/cert.crt"
10KEY_FILE="/path/to/local/cert.key"
11
12# List of remote hosts (IP addresses or hostnames)
13HOSTS=(
14 "192.168.1.10"
15 "192.168.1.11"
16 "192.168.1.12"
17)
18
19for 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"
29done
30
31echo "All certificates pushed successfully."
32