Skip to content
local-cert
Browse the documentation

certbot, acme.sh, lego

The three command-line clients. They are enough to equip any machine, and most of the integrations in the other guides rely on one of them.

ValueWhere to find itIn this guide
ACME directoryfixed for each instancehttps://certs.example.com/acme/directory
Key ID (kid)Keys & access → EAB credentialseab_XXXXXXXXXXXXXXXX
HMAC keyshown only once, at creationCLE_HMAC

certbot

Port 80 free on the machine: standalone mode.

certbot — standalone
certbot certonly --standalone -d nas.home.example.com \
  --server https://certs.example.com/acme/directory \
  --eab-kid eab_XXXXXXXXXXXXXXXX --eab-hmac-key CLE_HMAC \
  --email ops@example.com --agree-tos --no-eff-email

Port 80 in use: webroot mode, pointing to an empty folder.

certbot — webroot
mkdir -p /var/lib/letsencrypt/webroot
certbot certonly --webroot -w /var/lib/letsencrypt/webroot -d nas.home.example.com \
  --server https://certs.example.com/acme/directory \
  --eab-kid eab_XXXXXXXXXXXXXXXX --eab-hmac-key CLE_HMAC \
  --email ops@example.com --agree-tos --no-eff-email \
  --deploy-hook "systemctl reload nginx"

The files end up in /etc/letsencrypt/live/nas.home.example.com/. The server and the EAB are remembered in the renewal file: the certbot renew timer installed by the package renews with no further setup. Check with certbot renew --dry-run.

acme.sh

Registering the account is a separate step, done once per machine.

acme.sh
# 1. account, with the EAB
acme.sh --register-account --server https://certs.example.com/acme/directory \
  --eab-kid eab_XXXXXXXXXXXXXXXX --eab-hmac-key CLE_HMAC -m ops@example.com

# 2. issuance (webroot pointing to an empty folder)
mkdir -p /var/lib/acme-webroot
acme.sh --issue --server https://certs.example.com/acme/directory \
  -d nas.home.example.com -w /var/lib/acme-webroot

# 3. install the files and set the reload command
acme.sh --install-cert -d nas.home.example.com \
  --key-file       /etc/ssl/private/nas.home.example.com.key \
  --fullchain-file /etc/ssl/certs/nas.home.example.com.pem \
  --reloadcmd      "systemctl reload nginx"

With port 80 free, replace -w … with --standalone (socat required). Renewal runs through the cron job installed by acme.sh, so the webroot folder must exist permanently — hence a path outside /tmp.

lego

lego
lego --server https://certs.example.com/acme/directory \
  --eab --kid eab_XXXXXXXXXXXXXXXX --hmac CLE_HMAC \
  --email ops@example.com --accept-tos \
  --http --domains nas.home.example.com \
  run

The files end up in ./.lego/certificates/. lego doesn't install a scheduled job: schedule the same command yourself, ending with renew --days 30. With port 80 in use, add --http.webroot /var/lib/acme-webroot.

Verify

openssl
openssl x509 -in /etc/letsencrypt/live/nas.home.example.com/fullchain.pem -noout -issuer -subject -enddate

The issuer must be Let's Encrypt (or (STAGING) while local-cert is on the test environment). The certificate also shows up in Certificates.