I have one server where certbot is installed. And I get standalone certificates from this server, then I copy them to other web servers.
I run certbot with the command:
certbot certonly --manual --preferred-challenges=http --http-01-port 5557 --manual-auth-hook /etc/letsencrypt/example_val.sh --manual-cleanup-hook /etc/letsencrypt/example_clean.sh -d example.com -d example2.com
example_val.sh:
directories=(site1 site2)
ipaddr="192.168.0.20"
for dir in "${directories[@]}"; do
mydir="/var/www/${dir}/.well-known/acme-challenge"
ssh $ipaddr "[[ -d $mydir ]] || mkdir -p "$mydir""
ssh $ipaddr "echo $CERTBOT_VALIDATION > $mydir/$CERTBOT_TOKEN"
done
/etc/letsencrypt/example_clean.sh:
directories=(site1 site2)
ipaddr="192.168.0.20"
for dir in "${directories[@]}"; do
mydir="/var/www/${dir}/.well-known/acme-challenge"
ssh $ipaddr "rm -f $mydir/$CERTBOT_TOKEN"
done
rsync --copy-links -e "ssh -p $port" /etc/letsencrypt/live/example.com/fullchain.pem $ipaddr:/opt/certs/cert.pem
rsync --copy-links -e "ssh -p $port" /etc/letsencrypt/live/example.com/privkey.pem ``$ipaddr:/opt/certs/key.pem
ssh $ipaddr "service apache2 reload"
it gives error:
rsync: change_dir "/etc/letsencrypt/live/example.com" failed: No such file or directory (2)
Of course there is no /etc/letsencrypt/live/example.com directory - certbot shall create it.