Generate-DKIM-records-for-domain.sh

#! /bin/bash                          
read  -p "Enter New Domain: " domain
PRIVKEY=$domain.private
PUBKEY=$domain.public
openssl genrsa -out $domain.private 2048 2> /dev/null
openssl rsa -in $PRIVKEY -out $PUBKEY -pubout -outform PEM 2> /dev/null

cat $PUBKEY
chown -R yourMTA:yourMTA $domain.p*
chmod -R 600 $domain.p*

ssh-keygen -y -e -f "$PRIVKEY"
#diff <( ssh-keygen -y -e -f "$PRIVKEY" ) <( ssh-keygen -y -e -f "$PUBKEY" )
## crop first and last line of keyfile
sed '1d;$d' $domain.public > $domain.tmp  
## remove newlines from the key
dkim_key=$(tr -d '\n' < $domain.tmp)
rm $domain.tmp

## generate domainkey record and store to text file
echo "default._domainkey.$domain IN TXT \"v=DKIM1;k=rsa; p=$dkim_key\"" > $domain.dkim.txt

Popular posts from this blog

How to delete / clear queue of PowerMTA