Compare commits

...

28 Commits

Author SHA1 Message Date
Mateusz Gruszczyński
257fb6e98f fix import key to mikrotik 2025-10-27 09:57:47 +01:00
Mateusz Gruszczyński
d32885b732 fix import key to mikrotik 2025-10-27 09:53:54 +01:00
Mateusz Gruszczyński
e73027a3c8 logrotate 2025-10-27 09:44:54 +01:00
Mateusz Gruszczyński
0a4f4bf1d4 mikrotik services config 2025-10-27 09:38:17 +01:00
Mateusz Gruszczyński
561a3b23f6 mikrotik check cert 2025-10-27 09:30:41 +01:00
Mateusz Gruszczyński
c42250196f mikrotik check cert 2025-10-27 09:23:13 +01:00
Mateusz Gruszczyński
81d13e44eb mikrotik check cert 2025-10-27 09:21:24 +01:00
Mateusz Gruszczyński
dccad5d7a4 mikrotik check cert 2025-10-27 09:10:54 +01:00
Mateusz Gruszczyński
864ee27d01 mikrotik check cert 2025-10-27 09:02:09 +01:00
Mateusz Gruszczyński
f9e388f08e mikrotik check cert 2025-10-27 09:01:28 +01:00
Mateusz Gruszczyński
32c2dbc281 mikrotik check cert 2025-10-27 09:00:57 +01:00
Mateusz Gruszczyński
41dc2818f1 mikrotik check cert 2025-10-27 08:34:47 +01:00
Mateusz Gruszczyński
d3a10d2734 mikrotik check cert 2025-10-27 08:32:26 +01:00
Mateusz Gruszczyński
b8751516bd mikrotik check cert 2025-10-27 08:16:50 +01:00
Mateusz Gruszczyński
cb9eb16e96 mikrotik check cert 2025-10-27 08:12:12 +01:00
Mateusz Gruszczyński
2249136f16 mikrotik check cert 2025-10-27 08:06:45 +01:00
Mateusz Gruszczyński
9355644da1 mikrotik check cert 2025-10-27 08:03:38 +01:00
Mateusz Gruszczyński
b9ae19865c proxmox class 2025-10-27 07:58:05 +01:00
Mateusz Gruszczyński
afafb8aeef logging 2025-10-27 07:27:30 +01:00
Mateusz Gruszczyński
519f7ac5f2 logging 2025-10-27 07:25:48 +01:00
Mateusz Gruszczyński
62537ce93c logging 2025-10-27 07:22:27 +01:00
Mateusz Gruszczyński
f6a7a621f9 logging 2025-10-27 07:21:43 +01:00
Mateusz Gruszczyński
92f9e1edd1 logging 2025-10-27 07:18:12 +01:00
Mateusz Gruszczyński
5a37e451a5 mikrotik checks 2025-10-27 07:12:15 +01:00
Mateusz Gruszczyński
7fc8b3894c proxmox class 2025-10-26 23:41:57 +01:00
Mateusz Gruszczyński
736fdd2bac paramiko ds 2025-10-26 23:11:41 +01:00
Mateusz Gruszczyński
7fae370ef0 options 2025-10-26 23:07:37 +01:00
Mateusz Gruszczyński
4fc21ff635 options 2025-10-26 23:07:10 +01:00
5 changed files with 1033 additions and 146 deletions

1
.gitignore vendored
View File

@@ -9,3 +9,4 @@ config.ini
venv/
*.swp
.DS_Store
logs/*.log

View File

@@ -53,12 +53,17 @@ ssh-keygen -t ed25519 -f ~/.ssh/certpusher_key
ssh-copy-id -i ~/.ssh/certpusher_key.pub user@remote-host
2025-10-26 22:00:00 - CertPusher - INFO - ============================================================
2025-10-26 22:00:00 - CertPusher - INFO - CertPusher - SSL Certificate Distribution Tool
2025-10-26 22:00:00 - CertPusher - INFO - ============================================================
2025-10-26 22:00:01 - CertPusher - INFO - Processing host: webserver1
2025-10-26 22:00:02 - CertPusher - INFO - ✓ Successfully processed webserver1
## Security Considerations
- Store SSH private keys securely with proper permissions (chmod 600)

File diff suppressed because it is too large Load Diff

View File

@@ -1,40 +1,309 @@
# ╔═══════════════════════════════════════════════════════════╗
# ║ CertPusher Configuration File ║
# ║ SSL Certificate Distribution Configuration ║
# ╚═══════════════════════════════════════════════════════════╝
[global]
# Path to source SSL certificate (can be fullchain or single cert)
# Global source certificate and private key
source_cert_path = /etc/letsencrypt/live/example.com/fullchain.pem
source_key_path = /etc/letsencrypt/live/example.com/privkey.pem
# Default SSH key for all hosts (can be overridden per host)
default_ssh_key = /root/.ssh/id_rsa
[webserver1]
# ═══════════════════════════════════════════════════════════
# MIKROTIK DEVICES
# ═══════════════════════════════════════════════════════════
[mikrotik_router]
type = mikrotik
hostname = 172.16.0.1
port = 51022
username = admin
ssh_key_path = /root/.ssh/id_rsa_proxy
# Check certificate before upload (default: true)
check_before_upload = true
mikrotik_services = www-ssl,api-ssl
[mikrotik_switch]
type = mikrotik
hostname = 192.168.1.50
port = 22
username = admin
# Always upload without checking
check_before_upload = false
mikrotik_services = www-ssl,api-ssl
# ═══════════════════════════════════════════════════════════
# PROXMOX VE SERVERS
# ═══════════════════════════════════════════════════════════
[proxmox1]
type = proxmox
hostname = 10.87.2.150
port = 11922
username = root
check_url = https://10.87.2.150:8006
check_before_upload = true
[proxmox2]
type = proxmox
hostname = 10.87.2.151
port = 11922
username = root
check_url = https://10.87.2.151:8006
check_before_upload = true
# ═══════════════════════════════════════════════════════════
# HOME ASSISTANT INSTALLATIONS
# ═══════════════════════════════════════════════════════════
[homeassistant_supervised]
type = standard
hostname = 192.168.1.100
port = 22
username = root
remote_cert_path = /etc/nginx/ssl/certificate.pem
post_upload_command = systemctl reload nginx
remote_cert_path = /usr/share/hassio/ssl/fullchain.pem
remote_key_path = /usr/share/hassio/ssl/privkey.pem
post_upload_command = ha core restart
check_url = https://homeassistant.local:8123
[homeassistant_core]
type = standard
hostname = 192.168.1.101
port = 22
username = homeassistant
ssh_key_path = /root/.ssh/homeassistant_key
remote_cert_path = /home/homeassistant/.homeassistant/fullchain.pem
remote_key_path = /home/homeassistant/.homeassistant/privkey.pem
post_upload_command = sudo systemctl restart home-assistant@homeassistant
check_url = https://192.168.1.101:8123
[homeassistant_docker]
type = standard
hostname = 192.168.1.102
port = 22
username = root
remote_cert_path = /opt/homeassistant/config/fullchain.pem
remote_key_path = /opt/homeassistant/config/privkey.pem
post_upload_command = docker restart homeassistant
check_url = https://ha.example.com:8123
[homeassistant_haos]
type = standard
hostname = 192.168.1.103
port = 22
username = root
remote_cert_path = /ssl/fullchain.pem
remote_key_path = /ssl/privkey.pem
post_upload_command = ha core restart
check_url = https://192.168.1.103:8123
[homeassistant_nginx_proxy]
type = standard
hostname = 192.168.1.104
port = 22
username = root
remote_cert_path = /etc/nginx/ssl/homeassistant/fullchain.pem
remote_key_path = /etc/nginx/ssl/homeassistant/privkey.pem
post_upload_command = nginx -t && systemctl reload nginx
check_url = https://ha.example.com
# ═══════════════════════════════════════════════════════════
# WEB SERVERS (NGINX & APACHE)
# ═══════════════════════════════════════════════════════════
[webserver_nginx]
type = standard
hostname = 192.168.1.110
port = 22
username = root
remote_cert_path = /etc/nginx/ssl/fullchain.pem
remote_key_path = /etc/nginx/ssl/privkey.pem
post_upload_command = nginx -t && systemctl reload nginx
check_url = https://example.com
[webserver2]
hostname = 192.168.1.101
[webserver_apache]
type = standard
hostname = 192.168.1.111
port = 2222
username = admin
# Override SSH key for this host
ssh_key_path = /root/.ssh/webserver2_key
ssh_key_path = /root/.ssh/webserver_key
remote_cert_path = /etc/apache2/ssl/fullchain.pem
post_upload_command = systemctl reload apache2
remote_key_path = /etc/apache2/ssl/privkey.pem
post_upload_command = apachectl configtest && systemctl reload apache2
check_url = https://subdomain.example.com
[mailserver]
# ═══════════════════════════════════════════════════════════
# MAIL SERVERS (POSTFIX/DOVECOT)
# ═══════════════════════════════════════════════════════════
[mailserver_postfix]
type = standard
hostname = mail.example.com
port = 22
username = root
remote_cert_path = /etc/postfix/ssl/cert.pem
remote_key_path = /etc/postfix/ssl/privkey.pem
post_upload_command = systemctl restart postfix && systemctl restart dovecot
# No check_url - always upload
check_url = https://mail.example.com:587
[proxmox]
hostname = 10.0.0.50
# ═══════════════════════════════════════════════════════════
# DOCKER / CONTAINER PLATFORMS
# ═══════════════════════════════════════════════════════════
[docker_traefik]
type = standard
hostname = 10.0.0.60
port = 22
username = root
remote_cert_path = /etc/pve/local/pveproxy-ssl.pem
post_upload_command = systemctl restart pveproxy
check_url = https://10.0.0.50:8006
remote_cert_path = /opt/docker/traefik/certs/fullchain.pem
remote_key_path = /opt/docker/traefik/certs/privkey.pem
post_upload_command = docker restart traefik
check_url = https://traefik.example.com
[docker_nginx_proxy_manager]
type = standard
hostname = 10.0.0.61
port = 22
username = root
remote_cert_path = /opt/docker/npm/ssl/fullchain.pem
remote_key_path = /opt/docker/npm/ssl/privkey.pem
post_upload_command = docker exec nginx-proxy-manager nginx -s reload
check_url = https://npm.example.com
# ═══════════════════════════════════════════════════════════
# STORAGE / NAS DEVICES
# ═══════════════════════════════════════════════════════════
[truenas_scale]
type = standard
hostname = 10.0.0.70
port = 22
username = root
remote_cert_path = /etc/certificates/truenas_cert.crt
remote_key_path = /etc/certificates/truenas_cert.key
post_upload_command = midclt call system.general.ui_restart
check_url = https://truenas.local
[synology_nas]
type = standard
hostname = 10.0.0.71
port = 22
username = root
remote_cert_path = /usr/syno/etc/certificate/system/default/fullchain.pem
remote_key_path = /usr/syno/etc/certificate/system/default/privkey.pem
post_upload_command = /usr/syno/sbin/synoservicectl --reload nginx
check_url = https://synology.local:5001
# ═══════════════════════════════════════════════════════════
# HOSTS WITH CUSTOM CERTIFICATES
# ═══════════════════════════════════════════════════════════
[mailserver_custom_domain]
type = standard
hostname = mail.company.com
port = 22
username = root
# Override global certificate with domain-specific cert
source_cert_path = /etc/letsencrypt/live/mail.company.com/fullchain.pem
source_key_path = /etc/letsencrypt/live/mail.company.com/privkey.pem
remote_cert_path = /etc/postfix/ssl/cert.pem
remote_key_path = /etc/postfix/ssl/privkey.pem
post_upload_command = systemctl restart postfix && systemctl restart dovecot
check_url = https://mail.company.com:465
[api_server_subdomain]
type = standard
hostname = 192.168.1.200
port = 22
username = ubuntu
ssh_key_path = /root/.ssh/api_key
# API server with its own certificate
source_cert_path = /etc/letsencrypt/live/api.subdomain.org/fullchain.pem
source_key_path = /etc/letsencrypt/live/api.subdomain.org/privkey.pem
remote_cert_path = /etc/nginx/ssl/api/fullchain.pem
remote_key_path = /etc/nginx/ssl/api/privkey.pem
post_upload_command = systemctl reload nginx
check_url = https://api.subdomain.org
[client_website]
type = standard
hostname = 203.0.113.50
port = 2222
username = admin
# Client's own domain and certificate
source_cert_path = /etc/letsencrypt/live/client-domain.com/fullchain.pem
source_key_path = /etc/letsencrypt/live/client-domain.com/privkey.pem
remote_cert_path = /var/www/ssl/fullchain.pem
remote_key_path = /var/www/ssl/privkey.pem
post_upload_command = systemctl reload apache2
check_url = https://www.client-domain.com
[client_mikrotik]
type = mikrotik
hostname = 203.0.113.51
port = 22
username = admin
ssh_key_path = /root/.ssh/client_key
# Client's MikroTik with custom certificate
source_cert_path = /etc/letsencrypt/live/client-domain.com/fullchain.pem
source_key_path = /etc/letsencrypt/live/client-domain.com/privkey.pem
check_before_upload = true
# ═══════════════════════════════════════════════════════════
# DEVELOPMENT / STAGING SERVERS
# ═══════════════════════════════════════════════════════════
[dev_server]
type = standard
hostname = dev.local
port = 22
username = developer
# Dev server with staging certificate
source_cert_path = /etc/letsencrypt-staging/live/dev.example.com/fullchain.pem
source_key_path = /etc/letsencrypt-staging/live/dev.example.com/privkey.pem
remote_cert_path = /opt/app/ssl/fullchain.pem
remote_key_path = /opt/app/ssl/privkey.pem
post_upload_command = docker-compose restart nginx
# No check_url - always upload to dev environment
# ═══════════════════════════════════════════════════════════
# ADVANCED EXAMPLES
# ═══════════════════════════════════════════════════════════
[nginx_with_chain]
type = standard
hostname = 192.168.1.120
port = 22
username = root
remote_cert_path = /etc/nginx/ssl/cert.pem
remote_key_path = /etc/nginx/ssl/private/key.pem
# Upload additional chain file
additional_files = /etc/letsencrypt/live/example.com/chain.pem:/etc/nginx/ssl/chain.pem
post_upload_command = nginx -t && systemctl reload nginx
check_url = https://example.com
[apache_separate_dirs]
type = standard
hostname = 192.168.1.121
port = 22
username = root
# Certificate and key in completely different directories
remote_cert_path = /etc/ssl/certs/apache-cert.pem
remote_key_path = /etc/ssl/private/apache-key.pem
post_upload_command = apachectl configtest && systemctl reload apache2
[multi_service_host]
type = standard
hostname = 192.168.1.130
port = 22
username = root
remote_cert_path = /etc/ssl/certs/fullchain.pem
remote_key_path = /etc/ssl/private/privkey.pem
# Deploy cert to multiple services
additional_files = /etc/letsencrypt/live/example.com/fullchain.pem:/opt/app1/ssl/cert.pem,/etc/letsencrypt/live/example.com/privkey.pem:/opt/app1/ssl/key.pem,/etc/letsencrypt/live/example.com/fullchain.pem:/opt/app2/ssl/cert.pem
post_upload_command = systemctl reload nginx && systemctl restart app1 && systemctl restart app2
check_url = https://example.com

16
logrotate_certpusher Normal file
View File

@@ -0,0 +1,16 @@
/opt/certpusher/logs/*.log {
daily
rotate 7
compress
delaycompress
missingok
notifempty
create 0644 root root
dateext
dateformat -%Y%m%d
extension .log
nomail
postrotate
find /opt/certpusher/logs -name "*.log*" -type f -mtime +3 -delete
endscript
}