Automated Wildcard Certificate Sync for Proxmox VE
Proxmox-Sync-Wildcard is a Bash script designed to securely retrieve a wildcard TLS certificate for example.com from a remote Certificate Authority host and deploy it into a Proxmox VE clustered certificate store. The script uses SSH key-based authentication, maintains a complete backup of the Proxmox store, and reloads only the required service to minimize downtime.
- SSH Key Authentication: Secure, passwordless retrieval of certificates.
- Full-Store Backup: Archives the entire
/etc/pve/localdirectory before deployment. - Atomic Deployment: Ensures correct permissions and ownership for new certificates.
- Minimal Service Impact: Reloads only the
pveproxyservice to apply updates. - Error Checking: Validates SSH connectivity, file existence, and root privileges.
- Proxmox VE cluster with write access to
/etc/pve/local. - SSH key pair set up on both the Proxmox host and the remote CA server.
- The
certsyncuser on the CA host must have read access to/etc/letsencrypt/live/example.com.
-
SSH Key: Place your private key at the path specified by
SSH_KEY_PATH(default:/root/.ssh/id_rsa_proxmoxsync). -
Remote Host Details:
REMOTE_HOST: The CA host's address.REMOTE_USER: SSH user (e.g.,certsync).REMOTE_CERT_DIR: Path to the Let's Encrypt live directory forexample.org.
-
Local Paths:
- DOMAIN : Domain to be set and used for the certficate
PVE_STORE: Proxmox certificate store (/etc/pve/local).BACKUP_BASE: Base directory for backups (default:/root/backup/pve-local).
chmod +x sync.sh
sudo ./sync.shThe script will perform the following steps:
- Validate root privileges and SSH key readability.
- Test SSH connectivity to the CA server.
- Archive the existing
/etc/pve/localdirectory to a timestamped.tar.gz. - Download
fullchain.pemandprivkey.pemfrom the CA host. - Verify that both files are non-empty.
- Deploy the new certificates into
/etc/pve/localwith the correct permissions (0640,root:www-data). - Reload the
pveproxyservice. - Report success and the backup location.
- Errors are reported to STDERR, and the script exits with a non-zero code.
- All critical operations are wrapped in validation checks to prevent partial failures.
Integrate into your automation pipeline using cron or Ansible:
0 3 * * * /root/sync.sh >> /var/log/proxmox-cert-sync.log 2>&1This script is provided under the AGPL 3.0 License. See LICENSE file for details.