wiki-grav/pages/02.linux/acme-sh/default.en.md

82 lines
1.5 KiB
Markdown
Raw Normal View History

---
title: ACME.SH
visible: true
---
[toc]
2022-12-16 11:46:32 +01:00
## Getting ACME.SH
2022-12-16 11:46:32 +01:00
```sh
$ git clone https://github.com/acmesh-official/acme.sh.git
$ cd ./acme.sh
$ ./acme.sh --install -m my@example.com
```
## First time ZeroSSL registration
2022-12-16 11:46:32 +01:00
`$ (path to)/acme.sh --register-account -m (email)`
## Issue new certificate
2022-12-16 11:46:32 +01:00
Needs root to start a server on port 80
2022-12-16 11:46:32 +01:00
`# (path to)/acme.sh --issue --standalone -d (url)`
## Issue new certificate with DNS API
2022-12-16 11:46:32 +01:00
> [Official Documentation](https://github.com/acmesh-official/acme.sh/wiki/dnsapi)
### Gandi
2022-12-16 11:46:32 +01:00
`export GANDI_LIVEDNS_KEY="(api key)"`
`(path to)/acme.sh --issue --dns dns_gandi_livedns -d (domain)`
## Install certificate
2022-12-16 11:46:32 +01:00
Make sure to create the `/etc/acme-sh/(url)` directory
```sh
2022-09-11 17:36:46 +02:00
$ export url=woodpecker.exu.li \
&& mkdir -p /etc/acme-sh/{$url} \
&& .acme.sh/acme.sh --install-cert -d $url \
--key-file /etc/acme-sh/{$url}/key.pem \
--fullchain-file /etc/acme-sh/{$url}/cert.pem \
--reloadcmd "sudo systemctl restart nginx"
```
## Systems Service & Timer
2022-12-16 11:46:32 +01:00
`/etc/systemd/system/acme-sh.service`
```systemd
[Unit]
Description=Renew certificates using acme.sh
After=network-online.target
[Service]
Type=oneshot
ExecStart=(path to acme.sh) --cron --home (path to acme folder)
User=wiki
SuccessExitStatus=0 2
```
2022-12-16 11:46:32 +01:00
`/etc/systemd/system/acme.timer`
```systemd
[Unit]
Description=Daily renewal of certificates
[Timer]
OnCalendar=daily
RandomizedDelaySec=1h
Persistent=true
[Install]
WantedBy=timers.target
```
Enable timer
2022-12-16 11:46:32 +01:00
`systemctl enable --now acme-sh.timer`