GoAdmio

installdkim

Install OpenDKIM and configure it for GoAdmio, create the DKIM key of a domain, and print the DNS TXT value for it

On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also


Overview

DKIM signs outgoing mail so that other servers can confirm it really came from your domain. /go/installdkim sets up the server side of DKIM with OpenDKIM. It can:

It does not publish DNS records. Use dkim for that, and checkdkim to confirm the result. New accounts get their key automatically when they are created with create.


Quick start

# 1. Install and configure OpenDKIM (once per server)
/go/installdkim

# 2. Create the key of a domain
/go/installdkim example.com

# 3. Print the TXT value to publish in DNS
/go/installdkim example.com dns

Syntax

/go/installdkim
/go/installdkim <domain>
/go/installdkim <domain> dns
/go/installdkim all

If you run it without root, it re-runs itself with sudo.


Options

Form What it does
/go/installdkim Installs OpenDKIM and its tools, and writes the configuration.
/go/installdkim <domain> Creates the DKIM key for the domain and adds it to the OpenDKIM tables.
/go/installdkim <domain> dns Prints the TXT value for the domain's DNS record. It reads an existing key.
/go/installdkim all Runs dkim for every hosted domain that does not have a key yet.

The DKIM selector is always dkim, so the DNS record name is dkim._domainkey.<domain>.


Output

Form Output
Install Installing DKIM... followed by the output of the package manager.
Create a key Usually nothing. Blank lines can appear when the domain is already in a table.
dns One line, the TXT value: v=DKIM1; k=rsa; p=<public key>
all The output of dkim for each domain.

Each run also adds a line to /var/log/go/installdkim.log. The all form always ends with status 1.


Examples

# Install OpenDKIM
/go/installdkim
# Create a key for a domain
/go/installdkim example.com
# Print the TXT value for the domain's DNS
/go/installdkim example.com dns
v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A...
# Create keys for every domain that has none
/go/installdkim all
# Restart OpenDKIM so it reads the new tables
systemctl restart opendkim

Troubleshooting

Symptom Likely cause Fix
Mail is not signed OpenDKIM is not running, or Postfix is not connected to it. The command does not start the service. Restart OpenDKIM, and make sure Postfix uses the OpenDKIM service on inet:localhost:8891. See installmail.
checkdkim shows None or Invalid The DNS record is not published, or holds an old key. Publish the current value with dkim.
A new domain is not signed OpenDKIM has not read the updated tables. Restart OpenDKIM.
The dns form prints an empty value The key file /etc/opendkim/<domain>/dkim.txt does not exist. Create the key first with /go/installdkim <domain>.
The printed value is too short The public key is long and opendkim-genkey stored it in several quoted parts. The dns form prints only the first part. Build the value from the whole dkim.txt file by hand.
An odd line *@ dkim._domainkey. in SigningTable See Known issues. Delete the line, and restart OpenDKIM.
opendkim-genkey: command not found The OpenDKIM tools are not installed. This also happens on an unsupported operating system. Install opendkim-tools.

Details

Files

File Purpose
/etc/opendkim.conf OpenDKIM configuration. Overwritten by the install form.
/etc/opendkim/TrustedHosts Hosts that OpenDKIM treats as internal.
/etc/opendkim/KeyTable Maps each key name to its private key file.
/etc/opendkim/SigningTable Maps each sender domain to its key.
/etc/opendkim/<domain>/dkim.private The private key of the domain.
/etc/opendkim/<domain>/dkim.txt The public key in DNS format.

Install form

  1. Installs opendkim and opendkim-tools with dnf on AlmaLinux, Rocky, CentOS, Red Hat, and Fedora, or with apt on Debian and Ubuntu.

  2. Writes /etc/opendkim.conf with these main settings:

    Setting Value
    Selector dkim
    Mode sv (sign and verify)
    Canonicalization relaxed/simple
    SignatureAlgorithm rsa-sha256
    Socket inet:8891@localhost
    UserID opendkim:opendkim
    OversignHeaders From
    KeyTable, SigningTable, InternalHosts, ExternalIgnoreList The files in /etc/opendkim/
  3. On Debian and Ubuntu, also sets the daemon socket in /etc/default/opendkim to inet:8891@localhost, and the trust anchor file.

  4. Writes /etc/opendkim/TrustedHosts with 127.0.0.1, ::1, and the server host name.

  5. Adds the fixed domains described under Known issues.

  6. Creates the opendkim system user.

It does not start OpenDKIM, and it does not change the Postfix configuration.

Create a key

For /go/installdkim <domain>, the command:

  1. Creates /etc/opendkim/<domain>/ and generates the key pair there with opendkim-genkey and the selector dkim.
  2. Makes the opendkim user the owner of the folder.
  3. Adds the domain to TrustedHosts, KeyTable, and SigningTable, if it is not there yet.

Known issues


See also

Command Description
dkim Add a DKIM TXT record in Cloudflare (auto-generated or custom value)
checkdkim Check if a DKIM record is valid in GoAdmio
installmail Install and configure webmail services (Postfix and Dovecot)
installspf Install and configure the Postfix SPF policy daemon
installdmarc Install and configure OpenDMARC
create Create a GoAdmio account from the command line