Skip to content

Instantly share code, notes, and snippets.

@Jamie0
Created January 28, 2024 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jamie0/71c574dea0f974307b24ca0846b1ddff to your computer and use it in GitHub Desktop.
Save Jamie0/71c574dea0f974307b24ca0846b1ddff to your computer and use it in GitHub Desktop.
Script to nuke all _acme-challenge TXT records from a zone
#!/bin/bash
CF_ZONE_ID=x
curl -vk "https://api.cloudflare.com/client/v4/zones/$CF_ZONE_ID/dns_records?per_page=10000" \
-H "X-Auth-Email: $LEXICON_CLOUDFLARE_USERNAME" \
-H "X-Auth-Key: $LEXICON_CLOUDFLARE_TOKEN" \
| jq -rc ".result[] | select( .name | startswith(\"_acme-challenge.$CERTBOT_DOMAIN\")) .id" \
| grep . | tr '\n' '\0' \
| xargs -0 -n1 -I{} \
curl -vk "https://api.cloudflare.com/client/v4/zones/$CF_ZONE_ID/dns_records/{}" \
-H "X-Auth-Email: $LEXICON_CLOUDFLARE_USERNAME" \
-H "X-Auth-Key: $LEXICON_CLOUDFLARE_TOKEN" \
--request DELETE
@Jamie0
Copy link
Author

Jamie0 commented Jan 28, 2024

Please help, I am in Shell Scripting Hell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment