DKIM Postfix Debian

  • Category: 電腦相關
  • Last Updated: Saturday, 13 August 2022 21:21
  • Published: Saturday, 13 August 2022 21:00
  • Written by sam

After

Before

Install

ubuntu@myla:/# apt-get install opendkim opendkim-tools

Add User

ubuntu@myla:~# adduser opendkim

Genkey

ubuntu@myla:~# opendkim-genkey -b 2048 -d m.boredom.win -s 220813 -v
opendkim-genkey: generating private key
opendkim-genkey: private key written to 220813.private
opendkim-genkey: extracting public key
opendkim-genkey: DNS TXT record written to 220813.txt

Vi  Config and replace it.

ubuntu@myla:~# vi  /etc/opendkim.conf

# Sign for example.com with key in /etc/dkimkeys/dkim.key using
# selector '2007' (e.g. 2007._domainkey.example.com)
Domain                  boredom.win
KeyFile                 /etc/dkimkeys/dkim.private
Selector                220813
Mode                    sv

Vi Postfix Main.cf and ADD

ubuntu@myla:~# vi /etc/postfix/main.cf

## OpenDKIM
milter_protocol = 6
smtpd_milters = inet:localhost:8857
non_smtpd_milters = inet:localhost:8857

Add DNS Record to your DNS Server

ubuntu@myla:~# cat dkim.txt

dkim._domainkey IN      TXT     ( "v=DKIM1; h=sha256; k=rsa; t=y; "
          "p=MIIBIjANBgkqhkiG9 XX like that....

And then test it.

ubuntu@myla:~# systemctl restart postfix
ubuntu@myla:~# systemctl restart opendkim.service

opendkim-testkey -vvv -d boredom.win -s 220813
opendkim-testkey: using default configfile /etc/opendkim.conf
opendkim-testkey: key loaded from /etc/dkimkeys/dkim.private
opendkim-testkey: checking key '220813._domainkey.boredom.win'
opendkim-testkey: key not secure
opendkim-testkey: key OK

Or you can do it by Web

https://www.dmarcanalyzer.com/dkim/dkim-checker/