Getting Started

mkdir /etc/dehydrated
mkdir /root/software ; cd /root/software
yum -y install git python-dns python-pip
pip install --upgrade pip
pip install tld
git clone https://github.com/lukas2511/dehydrated.git
cd dehydrated
cp dehydrated /usr/local/bin

Install a hook of your choice, see below.

dehydrated --register --accept-terms

 

Cloudflare DNS hook

yum install -y gcc python-devel libffi-devel openssl-devel
pip install -r https://raw.githubusercontent.com/kappataumu/letsencrypt-cloudflare-hook/master/requirements-python-2.txt
wget https://raw.githubusercontent.com/kappataumu/letsencrypt-cloudflare-hook/master/hook.py -O /usr/local/bin/cloudflare_hook.py
chmod +x /usr/local/bin/cloudflare_hook.py
echo "export HOOK=cloudflare_hook.py" >> /etc/dehydrated/config
echo "export CF_EMAIL=user@example.com" >> /etc/dehydrated/config
echo "export CF_KEY=K9uX2HyUjeWg5AhAb" >> /etc/dehydrated/config
echo "export CF_DNS_SERVERS='8.8.8.8 8.8.4.4'" >> /etc/dehydrated/config 
echo "export CF_DEBUG=true" >> /etc/dehydrated/config

dehydrated --register --accept-terms

Alternative Mailgun support for manual mail hook

Get mail hook at https://github.com/bennettp123/dehydrated-email-notify-hook

wget https://raw.githubusercontent.com/bennettp123/dehydrated-email-notify-hook/master/hook.sh -O /usr/local/bin/mail_hook.sh
chmod +x /usr/local/bin/mail_hook.sh
nano /usr/local/bin/mail_hook.sh

Add this to the top

function send_mailgun {
	MAILGUN_DOMAIN="mg.your.domain.pt"
	MAILGUN_KEY="key-f6d842f572f6a905f51573993b210123"
	MAILGUN_FROM="x.your.domain.pt <sysadmins@your.domain.pt>"
	MAILGUN_TO="sysadmins@your.domain.pt"
	echo "   + Sending mail via Mailgun via domain $MAILGUN_DOMAIN to $MAILGUN_TO..."
	curl -s --user "api:$MAILGUN_KEY" \
		https://api.mailgun.net/v3/$MAILGUN_DOMAIN/messages \
		-F from="$MAILGUN_FROM" \
		-F to="$MAILGUN_TO" \
		-F subject="$SUBJECT" \
		-F text="$MESSAGE"
	echo ""
	
	return 0
}

Search for and comment:

echo "$MESSAGE" | mail -s "$SUBJECT" "$RECIPIENT"

Replace with:

send_mailgun

All domains

ls /etc/letsencrypt/live > /etc/dehydrated/domains.txt

dehydrated --cron  --challenge dns-01

One domain

dehydrated --cron --challenge dns-01 -d your.host.com

 

More Info

https://github.com/lukas2511/dehydrated#usage
https://github.com/lukas2511/dehydrated/wiki/Examples-for-DNS-01-hooks

Advertisements