Certbot commands cheat sheet

Certbot is a widely used tool for issuing free SSL certificates from Let's Encrypt and renewing them automatically. This cheat sheet brings together the commands for every stage: installing, issuing for Nginx and Apache, wildcard certificates, testing automatic renewal, hooks, revoking and deleting, and file locations. You can search for a command, filter by topic, and copy it with one click.

Installing

  • sudo snap install --classic certbot

    Installs Certbot as a snap package, the installation method the official Certbot site recommends today. The package includes the Nginx and Apache plugins. snapd must be installed on the server.

  • sudo ln -s /snap/bin/certbot /usr/local/bin/certbot

    Creates a link so the certbot command is available from any folder, as shown in the official installation instructions.

  • sudo apt-get remove certbot

    Before installing the snap, remove any certbot package installed from the distribution repositories, so the certbot command runs the snap version. On RHEL-family distributions and Fedora: sudo dnf remove certbot.

  • certbot --version

    Shows the installed Certbot version. Some options on this page exist only in recent versions.

  • sudo certbot plugins

    Shows the installed plugins: plugins that verify you control the domain, and plugins that install the certificate on the web server.

Issuing a certificate for a site

  • sudo certbot --nginx

    Issues a certificate and installs it in Nginx: Certbot shows the domains configured on the server, verifies that you control them, and edits the configuration files.

  • sudo certbot --nginx -d example.com -d www.example.com

    Issues one certificate for several names. Write each name after its own -d. The www address also counts as a separate name.

  • sudo certbot --apache

    Issues a certificate and installs it on an Apache server, the same way as the Nginx plugin.

  • sudo certbot certonly --nginx -d example.com

    Issues the certificate only, without editing the configuration files. You set up the certificate in the web server manually.

  • sudo certbot certonly --webroot -w /var/www/example -d example.com -d www.example.com

    Verifies control through the web server that's already running: Certbot writes a temporary file in the folder after -w, the site's root folder. This method works with any web server, with no service interruption.

  • sudo certbot certonly --standalone -d example.com

    Certbot runs its own temporary server to verify control, so port 80 must be free. When a web server already listens on port 80, stop it before issuing, or use the webroot method.

  • sudo certbot --nginx --redirect -d example.com

    Also adds an automatic redirect of all traffic from HTTP to HTTPS.

  • sudo certbot install --cert-name example.com

    Installs an already issued certificate on the web server, for example after issuing with certonly.

Wildcard certificates and DNS validation

  • sudo certbot certonly --manual --preferred-challenges dns -d example.com -d '*.example.com'

    Issues a wildcard certificate with DNS validation: Certbot asks you to add a TXT record named _acme-challenge to the domain. A wildcard certificate requires DNS validation. The certificate for *.example.com doesn't cover example.com itself, so write both. A certificate issued this way doesn't renew automatically.

  • sudo snap set certbot trust-plugin-with-root=ok

    The official instructions require this command before you install a DNS plugin as a snap package.

  • sudo snap install certbot-dns-cloudflare

    Installs the plugin for the DNS provider, here Cloudflare. Each supported DNS provider has its own plugin, and the plugin adds and removes the TXT record by itself.

  • chmod 600 ~/.secrets/certbot/cloudflare.ini

    Restricts the permissions of the file with the API credentials for the DNS provider, so other users on the server can't read it.

  • sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials ~/.secrets/certbot/cloudflare.ini -d example.com -d '*.example.com'

    Issues a wildcard certificate through the DNS plugin. This way, validation runs with no manual steps, and automatic renewal works too.

Testing before issuing

  • sudo certbot certonly --nginx --dry-run -d example.com

    Runs a test against the Let's Encrypt staging server, without saving a certificate. The --dry-run option works only with certonly and renew.

  • sudo certbot renew --dry-run

    Checks that renewing all certificates will succeed, without actually renewing them. Run it after every configuration change.

  • sudo certbot --nginx --test-cert -d example.com

    Issues a test certificate from the staging server. Browsers don't trust it, and it's for testing only, for example to stay within the issuance rate limits.

Viewing certificates and changing names

  • sudo certbot certificates

    Shows all the certificates Certbot manages: the certificate name, the domains, the expiration date, and the file locations.

  • sudo certbot certonly --nginx --cert-name example.com -d example.com -d www.example.com -d shop.example.com

    Changes the list of names on an existing certificate: write all the names the certificate should cover, and any name you leave out is removed from it. The certbot certificates command shows the certificate name.

  • sudo certbot --expand -d example.com,www.example.com,shop.example.com

    Adds names to an existing certificate. The official documentation recommends --cert-name, which also lets you remove names.

  • sudo certbot reconfigure --cert-name example.com --webroot-path /var/www/example

    Changes the renewal settings of an existing certificate, here the validation folder. Certbot runs a test renewal against the staging server and saves the new settings only if the test succeeds.

  • sudo certbot show_account

    Shows the details of the Let's Encrypt account that Certbot uses.

Renewing certificates

  • sudo certbot renew

    Renews all certificates that are due for renewal. A certificate is renewed when less than a third of its validity period remains, or earlier when the certificate authority recommends it.

  • sudo certbot renew --cert-name example.com

    Renews a single certificate only, if it's due for renewal.

  • sudo certbot renew --force-renewal --cert-name example.com

    Renews the certificate right away, even if it isn't due yet. Caution: repeated forced renewals can exceed the Let's Encrypt rate limits.

  • systemctl list-timers

    Shows the systemd scheduled tasks. When automatic renewal is set up as a timer, a certbot line appears in the list with the next run time.

  • sudo grep -rs certbot /etc/crontab /etc/cron.*

    Looks for the renewal task on servers where automatic renewal is set up in cron.

  • sudo certbot renew -q

    Renews with no output except errors. This command suits running from a cron job.

  • /etc/letsencrypt/renewal/example.com.conf

    The certificate's renewal configuration file. The official documentation recommends not editing it manually, because a wrong edit can break renewal. To change the settings, use certbot reconfigure.

Actions before and after renewal (hooks)

  • sudo certbot renew --deploy-hook 'systemctl reload nginx'

    Reloads Nginx after a successful renewal, so the server starts using the new certificate. A deploy hook runs only when a certificate was renewed successfully.

  • sudo certbot renew --pre-hook 'systemctl stop nginx' --post-hook 'systemctl start nginx'

    Actions that run before and after each renewal attempt, for example stopping the web server to free port 80 for the standalone method. They run only when a certificate is due for renewal.

  • sudo certbot reconfigure --cert-name example.com --deploy-hook 'systemctl reload nginx'

    Saves a deploy hook in the renewal settings of an existing certificate, so it also runs during automatic renewal.

  • /etc/letsencrypt/renewal-hooks/deploy/

    Executable files in this folder run after every successful renewal, in alphabetical order. Likewise, the files in the pre and post folders next to it run before and after a renewal attempt.

Keys, profiles, and automation

  • sudo certbot certonly --nginx --key-type ecdsa -d example.com

    Issues a certificate with an ECDSA key. This is Certbot's default for new certificates, with the secp256r1 (P-256) curve.

  • sudo certbot certonly --nginx --key-type rsa --rsa-key-size 4096 -d example.com

    Issues a certificate with an RSA key, for example for older systems that don't support ECDSA. The default RSA key size is 2048.

  • sudo certbot renew --key-type ecdsa --cert-name example.com --force-renewal

    Changes the key type of an existing certificate. Unless you ask for a change explicitly, a certificate keeps renewing with its own key type.

  • sudo certbot certonly --nginx --preferred-profile tlsserver -d example.com

    Requests a specific certificate profile. At Let's Encrypt, the tlsserver profile issues certificates for 45 days, and the classic profile, the default, for 90 days. The option exists only in recent versions of Certbot.

  • sudo certbot --nginx --non-interactive --agree-tos -m admin@example.com -d example.com

    Issues with no prompts, for use in scripts: agrees to the terms of service and sets an email address for important account notices.

Files and logs

  • /etc/letsencrypt/live/example.com/fullchain.pem

    The site's certificate together with the intermediate certificates. This is the file you set in the web server, for example in the Nginx ssl_certificate directive.

  • /etc/letsencrypt/live/example.com/privkey.pem

    The certificate's private key. Keep it secret, and never share it with anyone.

  • /etc/letsencrypt/live/example.com/chain.pem

    This file holds only the intermediate certificates, and cert.pem holds only the site's certificate. Software that asks for the certificate and the chain separately needs both files.

  • /etc/letsencrypt/live/

    The files in this folder are updated on every renewal. Point the web server at them directly or through symbolic links. Don't copy them, or the server keeps using the old certificate. Never delete files from /etc/letsencrypt manually.

  • sudo tail -n 50 /var/log/letsencrypt/letsencrypt.log

    Shows the last lines of the Certbot log, which records the reason an issuance or renewal failed.

  • sudo openssl x509 -in /etc/letsencrypt/live/example.com/cert.pem -noout -enddate

    Shows the certificate's expiration date from the file on the server.

Revoking and deleting

  • sudo certbot revoke --cert-name example.com

    Revokes the certificate with the certificate authority, for example when the private key was exposed. Caution: a revoked certificate is no longer valid, so issue a replacement first. Certbot asks whether to also delete the files, and a revoked certificate that wasn't deleted is renewed on the next certbot renew run.

  • sudo certbot delete --cert-name example.com

    Deletes the certificate and its renewal settings from the server, without revoking it with the certificate authority. Caution: this can't be undone. Before deleting, remove the references to the certificate from the web server configuration, or the server may fail to start.

Certificate lifetime and rate limits

  • Validity period: Let's Encrypt certificates are currently valid for 90 days. Under the schedule Let's Encrypt has published, certificates issued from February 10, 2027 will be valid for 64 days, and certificates issued from February 16, 2028 will be valid for 45 days. Recent versions of Certbot renew a certificate when less than a third of its validity period remains, and also check the renewal window Let's Encrypt publishes (ARI), so automatic renewal also suits the shorter certificates. A cron job or script that renews after a fixed number of days, for example every 60 days, needs to be updated.
  • Rate limits: Let's Encrypt limits the number of certificates, for example 50 certificates per registered domain and 5 certificates for the exact same set of names, every 7 days. Run your tests with --dry-run or --test-cert. The current limits are listed on the Let's Encrypt rate limits page.
  • OCSP: Let's Encrypt stopped providing OCSP in 2025, so don't use the --must-staple option with its certificates.

The domain example.com and the paths on this page are examples, so replace them with your real values. You can check the certificate your site actually serves with the SSL certificate checker, and the security messages browsers show are explained on the common browser SSL errors page.

Did you know?

With our web hosting plans, an SSL certificate is activated for your site with one click, at no cost, and it renews automatically, with no commands needed. On a Linux VPS, you connect over SSH with full root access, and install and run Certbot with every command on this page.

Linux VPS plans

Certbot FAQ

What is Certbot, and how does it work with Let's Encrypt?

Certbot is a tool that issues free SSL certificates from Let's Encrypt and renews them automatically. Before issuing, Let's Encrypt checks that you control the domain, and Certbot handles the validation itself, usually with a temporary file on the site or a TXT record in DNS. With the Nginx and Apache plugins, Certbot also installs the certificate in the web server.

How do I check that automatic certificate renewal works?

Run sudo certbot renew --dry-run: the command simulates renewing all certificates and shows whether renewal will succeed. The renewal task itself appears in the output of systemctl list-timers, or in the cron jobs on servers where renewal is set up that way. The sudo certbot certificates command shows each certificate's expiration date, and you can check the certificate your site actually serves with the SSL certificate checker.

How do I get a wildcard certificate with Certbot?

A wildcard certificate requires DNS validation. The easy way is a DNS plugin for your DNS provider, which adds the validation record by itself and allows automatic renewal. Without a plugin, you can run certbot certonly --manual --preferred-challenges dns and add the TXT record manually, but a certificate issued this way doesn't renew automatically. The certificate for *.example.com doesn't cover example.com itself, so request both names.

How do I add a domain to an existing certificate?

Run the issuing command with --cert-name and the certificate name, and after -d write all the names the certificate should cover, including the existing ones. Certbot replaces the certificate with a new one that has the full list of names. The sudo certbot certificates command shows the certificate name and the names it currently covers.

What's the difference between certbot --nginx and certbot certonly?

The certbot --nginx command issues the certificate and also sets it up in the Nginx configuration files. The certbot certonly command only issues the certificate, and you set it up in the web server manually. Use certonly when you want control over the configuration files, or when another service uses the certificate, such as a mail server.

Shopping cart

Your cart is emptyYou can start with one of our popular plans.

Site search

Accessibility

Text size
100%
Accessibility statement