Error creating DKIM keys

Following the steps of: How to Manually Set up SPF, DKIM and DMARC Inside CyberPanel, when writing the command: opendkim-default-keygen in the terminal generates the following error:

Generating default DKIM keys:
Can not determine host’s domain name, skipping default key generation.

They can support me to fix this problem.

did you follow step by step?
Maybe missing something

Hello hassan_noor.

If I did, step by step. But at this point Step 2: Generate DKIM keys throws me the problem.

Perform a mail test for the sending and receiving and notice something rare in this part (server.example.com) here does not show me hostname that I have. Will it be a problem with Postfix ???

Received: from clipxio.ml (localhost [IPv6 ::: 1]) (Authenticated sender: [email protected]) by server.example.com (Postfix) with ESMTPSA id C7201AAB for [email protected]; Fri, 20 Apr 2018 00:52:33 -0400 (EDT)

Any other way that can generate the keys for DKIM?

Hello @anunnaki , that article was written by me.

Seeing your issue, I feel that opendkim-default-keygen is very generalized step which works on most of the systems but tends to mess sometimes as that command tries to create the DKIM keys for the Linux’s hostname only. That step also does not works for the users who want to sign DKIM keys for more than one domain on the same VPS.

It might gave that error, because you didn’t had your hostname correctly configured in Linux.

Anyways, I will revise that article shortly. Right now, I’m posting here the steps required to do from your side as of now :

You will need to generate the keys using these commands for your specific domain(s) by the following commands.

“mkdir /etc/opendkim/keys/example.com” (A directory in which the keys will reside)

“/usr/sbin/opendkim-genkey -D /etc/opendkim/keys/example.com/ -d yourdomain.com -s default” (generating keys for your specific domain and not the default hostname).

Then the permissions stuff by the following commands so OpenDKIM doesn’t have any issues reading the keys :-

“chown -R root:opendkim /etc/opendkim/keys/yourdomain.com”
“chmod 640 /etc/opendkim/keys/yourdomain.com/default.private”
“chmod 644 /etc/opendkim/keys/yourdomain.com/default.txt”

And after that, same steps for SigningHosts and other config files with yourdomain.com and it’s folder in the config files respectively.

The steps after this should work the same way and this method can also be used to let the OpenDKIM work for more than one e-mail Domains on the same Server.

Hope it works for you now or you got the idea how it works. ::smile:

Post here any problems if you face after this.