lego Commands Reference
Single-binary ACME client written in Go with 200+ DNS providers. Examples target lego v5 (unified run, redesigned CLI).
๐ฆ Installation
Homebrew
brew install legoGo install
go install github.com/go-acme/lego/v5/cmd/lego@latestDocker
docker run --rm goacme/lego -hโ ๏ธ Migrating from v4
Run this once before any other v5 command. Do not hand-edit the storage directory โ layout and JSON format changed.
lego migrate
lego migrate --path /path/to/lego/storagerenewremoved โ userun- Flags belong on the subcommand:
lego run --dns โฆ -d โฆ list/revokeโcertificates list/certificates revoke--run-hook/--renew-hookโ--deploy-hook
๐ Issue & renew
HTTP-01
lego run --email [email protected] --http -d example.comObtains a cert if missing, renews when due. Port 80 must be reachable by the CA.
DNS-01 (Cloudflare)
CLOUDFLARE_DNS_API_TOKEN=... \
lego run --email [email protected] --dns cloudflare \
-d '*.example.com' -d example.comToken needs Zone:Read and DNS:Edit. Prefer API tokens over Global API keys.
Deploy hook
lego run --email [email protected] --http -d example.com --deploy-hook='./deploy.sh'๐ Manage certificates
lego certificates list
lego certificates revoke -d example.com
lego accounts list๐ See Also
Docs: go-acme.github.io/lego