The question is a bit dated, but the following configuration works for me.
The selector is usually default, but can be anything as long as you don't have multiple keys with the same selector.
SELECTOR=default
DOMAIN=domain.tld
# Add a rule for the new domain to the signing table (location of the signing table should be configured in opendkim.conf)
echo -e "*@${DOMAIN} ${SELECTOR}._domainkey.${DOMAIN}" | sudo tee -a /etc/opendkim/SigningTable
# Add the path to the key to the key table (again, defined in opendkim.conf)
echo -e "${SELECTOR}._domainkey.${DOMAIN} ${DOMAIN}:${SELECTOR}:/etc/opendkim/keys/${DOMAIN}/${SELECTOR}.private" | sudo tee -a /etc/opendkim/KeyTable
# Add the domain to the trusted hosts (I think this is not necessary if you send from localhost)
echo -e "${DOMAIN}" | sudo tee -a /etc/opendkim/TrustedHosts
# Create a directory for the domain's key
sudo mkdir -p /etc/opendkim/keys/${DOMAIN}
# Create the key
sudo opendkim-genkey -b 1024 -d ${DOMAIN} -D /etc/opendkim/keys/${DOMAIN} -s ${SELECTOR} -v
# Set the right ownership for the newly generated key
sudo chown opendkim: /etc/opendkim/keys -R
# This is the public key and must be added to your dns record
sudo cat /etc/opendkim/keys/${DOMAIN}/${SELECTOR}.txt
This was my source:
https://easydmarc.com/blog/how-to-configure-dkim-opendkim-with-postfix/