|
| 1 | + 1. Ensure that GPG is installed and configured. Also make sure public keys for |
| 2 | + all of your potential recipients are available in the GPG home directory |
| 3 | + used for `keyhome` in step 2. |
| 4 | + 2. Configure `/etc/gpg-mailgate.conf` based on the provided |
| 5 | + `gpg-mailgate.conf.sample` |
| 6 | + 3. Place `gpg-mailgate.py` in `/usr/local/bin/` |
| 7 | + 4. Place the GnuPG directory in `/usr/lib/python2.7/` (replace 2.7 with your |
| 8 | + Python version) |
| 9 | + 5. Add the following to the end of `/etc/postfix/master.cf` |
| 10 | + |
| 11 | + gpg-mailgate unix - n n - - pipe |
| 12 | + flags= user=nobody argv=/usr/local/bin/gpg-mailgate.py ${recipient} |
| 13 | + |
| 14 | + 127.0.0.1:10028 inet n - n - 10 smtpd |
| 15 | + -o content_filter= |
| 16 | + -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks |
| 17 | + -o smtpd_helo_restrictions= |
| 18 | + -o smtpd_client_restrictions= |
| 19 | + -o smtpd_sender_restrictions= |
| 20 | + -o smtpd_recipient_restrictions=permit_mynetworks,reject |
| 21 | + -o mynetworks=127.0.0.0/8 |
| 22 | + -o smtpd_authorized_xforward_hosts=127.0.0.0/8 |
| 23 | + |
| 24 | + 6. Add the following to `/etc/postfix/main.cf` |
| 25 | + |
| 26 | + content_filter = gpg-mailgate |
| 27 | + |
| 28 | + 7. Restart postfix. |
| 29 | + |
| 30 | + |
| 31 | +## Note 1 |
| 32 | + |
| 33 | +It is possible to create a dedicated user to store the PGP public keys with |
| 34 | +these example commands: |
| 35 | + |
| 36 | + useradd -s /bin/false -d /var/gpg -M gpgmap |
| 37 | + mkdir -p /var/gpg/.gnupg |
| 38 | + chown -R gpgmap /var/gpg |
| 39 | + chmod 700 /var/gpg/.gnupg |
| 40 | + sudo -u gpgmap /usr/bin/gpg --import /home/youruser/public.key --homedir=/var/gpg/.gnupg |
| 41 | + |
| 42 | + - Replace `/home/youruser/public.key` with the location of your public key |
| 43 | + - `/home/youruser/public.key` can be deleted after importation |
| 44 | + - Confirm that it's working: `sudo -u gpgmap /usr/bin/gpg --list-keys --homedir=/var/gpg/.gnupg` |
| 45 | + - Use `keyhome = /var/gpg/.gnupg` in `gpg-mailgate.conf` |
0 commit comments