Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generate DKIM key pair and entry for in your bind zones.
#!/bin/sh
DOMAIN=$1
SELECTOR=${2:-mail}
if [ -z "$DOMAIN" ]; then
echo "Usage: $0 domain"
exit 1;
fi
openssl genrsa -out dkim-${DOMAIN}.key 2048
openssl rsa -in dkim-${DOMAIN}.key -out dkim-${DOMAIN}.pub -pubout -outform PEM
DNS=`cat dkim-${DOMAIN}.pub | grep -v "-"`
echo "Add the following record to your DNS zone."
echo "##########################################"
echo ""
echo "${SELECTOR}._domainkey IN TXT ( \"v=DKIM1; t=y; k=rsa; p=\""
for line in $DNS; do
echo "\t\"${line}\""
done
echo ")"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment