Skip to content

Instantly share code, notes, and snippets.

@everdaniel
Forked from fideloper/certbot.sh
Created January 3, 2024 03:49
Show Gist options
  • Save everdaniel/64be4e5ebd0f1b13ac745a9c47a2a2f8 to your computer and use it in GitHub Desktop.
Save everdaniel/64be4e5ebd0f1b13ac745a9c47a2a2f8 to your computer and use it in GitHub Desktop.

Revisions

  1. @fideloper fideloper revised this gist Feb 7, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions certbot.sh
    Original file line number Diff line number Diff line change
    @@ -26,6 +26,7 @@ sudo chmod 0600 /etc/letsencrypt/dnscloudflare.ini
    # Create a certificate!
    # This has nginx reload upon renewal,
    # which assumes Nginx is using the created certificate
    # You can also create non-wildcard subdomains, e.g. "-d foo.example.org"
    sudo certbot certonly -d *.example.org \
    --dns-cloudflare --dns-cloudflare-credentials /etc/letsencrypt/dnscloudflare.ini \
    --post-hook "service nginx reload" \
  2. @fideloper fideloper created this gist Feb 7, 2022.
    36 changes: 36 additions & 0 deletions certbot.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    # Used on Ubuntu 18.04 and 20.04
    # Find instructions for other OSes here: https://certbot.eff.org/instructions

    # Install Certbot via Snaps
    sudo snap install core; sudo snap refresh core
    sudo snap install --classic certbot
    sudo ln -s /snap/bin/certbot /usr/bin/certbot

    # Install DNS CloudFlare plugin
    sudo snap set certbot trust-plugin-with-root=ok
    sudo snap install certbot-dns-cloudflare

    # This directory may not exist yet
    sudo mkdir -p /etc/letsencrypt


    # Create file with the Cloudflare API token
    sudo tee /etc/letsencrypt/dnscloudflare.ini > /dev/null <<EOT
    # Cloudflare API token used by Certbot
    dns_cloudflare_api_token = AN_API_TOKEN_HERE
    EOT

    # Secure that file (otherwise certbot yells at you)
    sudo chmod 0600 /etc/letsencrypt/dnscloudflare.ini

    # Create a certificate!
    # This has nginx reload upon renewal,
    # which assumes Nginx is using the created certificate
    sudo certbot certonly -d *.example.org \
    --dns-cloudflare --dns-cloudflare-credentials /etc/letsencrypt/dnscloudflare.ini \
    --post-hook "service nginx reload" \
    --non-interactive --agree-tos \
    --email [email protected]

    # Test it out
    sudo certbot renew --dry-run