]> git.proxmox.com Git - pmg-docs.git/blame - pmgconfig.adoc
dkim: document dkim-use-domain
[pmg-docs.git] / pmgconfig.adoc
CommitLineData
e62ceaf0
DM
1[[chapter_pmgconfig]]
2ifdef::manvolnum[]
3pmgconfig(1)
4============
5:pmg-toplevel:
6
7NAME
8----
9
10pmgconfig - Proxmox Mail Gateway Configuration Management Toolkit
11
12
13SYNOPSIS
14--------
15
16include::pmgconfig.1-synopsis.adoc[]
17
18
19DESCRIPTION
20-----------
21endif::manvolnum[]
22ifndef::manvolnum[]
66e9c719
DM
23Configuration Management
24========================
e62ceaf0
DM
25:pmg-toplevel:
26endif::manvolnum[]
27
a4f14219
TL
28{pmg} is usually configured using the web-based Graphical User Interface (GUI),
29but it is also possible to directly edit the configuration files, using the
db96e742 30REST API over 'https' or the command-line tool `pmgsh`.
685576c2 31
db96e742 32The command-line tool `pmgconfig` is used to simplify some common configuration
a4f14219
TL
33tasks, such as generating certificates and rewriting service configuration
34files.
685576c2 35
a4f14219
TL
36NOTE: We use a Postgres database to store mail filter rules and statistical
37data. See chapter xref:chapter_pmgdb[Database Management] for more information.
66e9c719
DM
38
39
40Configuration files overview
41----------------------------
42
43`/etc/network/interfaces`::
44
3f18659b 45Network setup. We never modify this file directly. Instead, we write
eb269701
DW
46changes to `/etc/network/interfaces.new`. When you reboot, {pmg} renames
47the file to `/etc/network/interfaces`, thus applying the changes.
66e9c719 48
9bfe27f3
DM
49`/etc/resolv.conf`::
50
fa483193
SI
51DNS search domain and nameserver setup. {pmg} uses the search domain setting
52to create the FQDN and domain name used in the postfix configuration.
9bfe27f3
DM
53
54`/etc/hostname`::
55
eb269701 56The system's hostname. {pmg} uses the hostname to create the FQDN used
fa483193 57in the postfix configuration.
9bfe27f3
DM
58
59`/etc/hosts`::
60
61Static table lookup for hostnames.
62
66e9c719
DM
63`/etc/pmg/pmg.conf`::
64
eb269701
DW
65Stores common administration options, such as the spam and mail proxy
66configuration.
66e9c719
DM
67
68`/etc/pmg/cluster.conf`::
69
70The cluster setup.
71
72`/etc/pmg/domains`::
73
74The list of relay domains.
75
5053eecc
SI
76`/etc/pmg/dkim/domains`::
77
78The list of domains for outbound DKIM signing.
79
66e9c719
DM
80`/etc/pmg/fetchmailrc`::
81
82Fetchmail configuration (POP3 and IMAP setup).
83
84`/etc/pmg/ldap.conf`::
85
86LDAP configuration.
87
88`/etc/pmg/mynetworks`::
89
90List of local (trusted) networks.
91
92`/etc/pmg/subscription`::
93
94Stores your subscription key and status.
95
37b2b051
SI
96`/etc/pmg/tls_policy`::
97
98TLS policy for outbound connections.
99
374bcb5f
CH
100`/etc/pmg/tls_inbound_domains`::
101
102Sender domains for which TLS is enforced on inbound connections.
103
f43c6983 104`/etc/pmg/transport`::
66e9c719
DM
105
106Message delivery transport setup.
107
108`/etc/pmg/user.conf`::
109
110GUI user configuration.
111
797db11d
DM
112`/etc/mail/spamassassin/custom.cf`::
113
114Custom {spamassassin} setup.
115
8b4756e5
SI
116`/etc/mail/spamassassin/pmg-scores.cf`::
117
118Custom {spamassassin} rule scores.
66e9c719
DM
119
120Keys and Certificates
121---------------------
122
123`/etc/pmg/pmg-api.pem`::
124
eb269701 125Key and certificate (combined) used by the HTTPS server (API).
66e9c719
DM
126
127`/etc/pmg/pmg-authkey.key`::
128
eb269701 129Private key used to generate authentication tickets.
66e9c719
DM
130
131`/etc/pmg/pmg-authkey.pub`::
132
eb269701 133Public key used to verify authentication tickets.
66e9c719
DM
134
135`/etc/pmg/pmg-csrf.key`::
136
137Internally used to generate CSRF tokens.
138
139`/etc/pmg/pmg-tls.pem`::
140
141Key and certificate (combined) to encrypt mail traffic (TLS).
142
5053eecc
SI
143`/etc/pmg/dkim/<selector>.private`::
144
145Key for DKIM signing mails with selector '<selector>'.
146
66e9c719 147
69a428d9 148[[pmgconfig_template_engine]]
66e9c719
DM
149Service Configuration Templates
150-------------------------------
151
eb269701 152{pmg} uses various services to implement mail filtering, for example,
9c85cc80 153the {postfix} Mail Transport Agent (MTA), the {clamav} antivirus
eb269701
DW
154engine, and the Apache {spamassassin} project. These services use
155separate configuration files, so we need to rewrite those files when the
9c85cc80
DM
156configuration is changed.
157
eb269701 158We use a template-based approach to generate these files. The {tts} is
9c85cc80
DM
159a well known, fast and flexible template processing system. You can
160find the default templates in `/var/lib/pmg/templates/`. Please do not
eb269701 161modify these directly, otherwise your modifications will be lost on the
9dd45bd7
SI
162next update. Instead, copy the template you wish to change to
163`/etc/pmg/templates/`, then apply your changes there.
9c85cc80 164
eb269701 165Templates can access any configuration settings, and you can use the
9c85cc80
DM
166`pmgconfig dump` command to get a list of all variable names:
167
168----
169# pmgconfig dump
170...
171dns.domain = yourdomain.tld
172dns.hostname = pmg
173ipconfig.int_ip = 192.168.2.127
174pmg.admin.advfilter = 1
175...
176----
177
eb269701
DW
178The same tool is used to force the regeneration of all template-based
179configuration files. You need to run the following after modifying a template,
180or when you directly edit configuration files:
9c85cc80
DM
181
182----
183# pmgconfig sync --restart 1
184----
185
9dd45bd7 186The above command also restarts services if the underlying configuration
9c85cc80
DM
187files are changed. Please note that this is automatically done when
188you change the configuration using the GUI or API.
189
190NOTE: Modified templates from `/etc/pmg/templates/` are automatically
191synced from the master node to all cluster members.
66e9c719 192
7e7126d6
ML
193[[pmgconfig_whitelist_overview]]
194White- and Blacklists
195---------------------
196
eb269701
DW
197{pmg} has multiple white- and blacklists. It differentiates between the
198xref:pmgconfig_mailproxy_options[SMTP Whitelist], the rule-based whitelist
7e7126d6 199and the user whitelist.
eb269701 200In addition to the whitelists, there are two separate blacklists: the rule-based
7e7126d6
ML
201blacklist and the user blacklist.
202
203SMTP Whitelist
204~~~~~~~~~~~~~~
205
61b59f73 206The xref:pmgconfig_mailproxy_whitelist[SMTP Whitelist] is responsible for disabling
eb269701 207greylisting, as well as SPF and DNSBL checks. These are done during the SMTP
7e7126d6
ML
208dialogue.
209
210Rule-based White-/Blacklist
211~~~~~~~~~~~~~~~~~~~~~~~~~~~
212
213The xref:chapter_mailfilter[rule-based white- and blacklists] are predefined
eb269701
DW
214rules. They work by checking the attached 'Who' objects, containing, for
215example, a domain or a mail address for a match. If it matches, the assigned
216action is used, which by default is 'Accept' for the whitelist rule and 'Block'
217for the blacklist rule. In the default setup, the blacklist rule has priority
218over the whitelist rule and spam checks.
7e7126d6
ML
219
220User White-/Blacklist
221~~~~~~~~~~~~~~~~~~~~~
222
223The user white- and blacklist are user specific. Every user can add mail addresses
224to their white- and blacklist. When a user adds a mail address to the whitelist,
225the result of the spam analysis will be discarded for that recipient. This can
eb269701
DW
226help in the mail being accepted, but what happens next still depends on the
227other rules. In the default setup, this results in the mail being accepted for
7e7126d6
ML
228this recipient.
229
eb269701
DW
230For mail addresses on a user's blacklist, the spam score will be increased by
231100. What happens when a high spam score is encountered still depends on the
232rule system. In the default setup, it will be recognized as spam and quarantined
7e7126d6 233(spam score of 3 or higher).
66e9c719 234
4a08dffe 235[[pmgconfig_systemconfig]]
685576c2
DM
236System Configuration
237--------------------
238
239Network and Time
240~~~~~~~~~~~~~~~~
241
242ifndef::manvolnum[]
38d14519 243[thumbnail="screenshot/pmg-gui-network-config.png", big=1]
685576c2
DM
244endif::manvolnum[]
245
eb269701
DW
246As network and time are configured in the installer, these generally do not
247need to be configured again in the GUI.
45de5bf5
DM
248
249The default setup uses a single Ethernet adapter and static IP
250assignment. The configuration is stored at '/etc/network/interfaces',
eb269701 251and the actual network setup is done the standard Debian way, using the
45de5bf5
DM
252package 'ifupdown'.
253
254.Example network setup '/etc/network/interfaces'
255----
256source /etc/network/interfaces.d/*
257
258auto lo
259iface lo inet loopback
260
261auto ens18
262iface ens18 inet static
263 address 192.168.2.127
264 netmask 255.255.240.0
265 gateway 192.168.2.1
266----
267
268.DNS recommendations
269
270Many tests to detect SPAM mails use DNS queries, so it is important to
3f18659b 271have a fast and reliable DNS server. We also query some publicly
45de5bf5
DM
272available DNS Blacklists. Most of them apply rate limits for clients,
273so they simply will not work if you use a public DNS server (because
274they are usually blocked). We recommend to use your own DNS server,
3f18659b 275which needs to be configured in 'recursive' mode.
685576c2
DM
276
277
278Options
279~~~~~~~
280
281ifndef::manvolnum[]
38d14519 282[thumbnail="screenshot/pmg-gui-system-options.png", big=1]
685576c2
DM
283endif::manvolnum[]
284
e09057ab 285
eb269701 286These settings are saved to the 'admin' subsection in `/etc/pmg/pmg.conf`,
e09057ab
DM
287using the following configuration keys:
288
685576c2
DM
289include::pmg.admin-conf-opts.adoc[]
290
c331641e 291
8c889e95
TL
292include::pmg-ssl-certificate.adoc[]
293
c331641e
DM
294Mail Proxy Configuration
295------------------------
296
4a08dffe 297[[pmgconfig_mailproxy_relaying]]
c331641e
DM
298Relaying
299~~~~~~~~
300
c331641e 301ifndef::manvolnum[]
38d14519 302[thumbnail="screenshot/pmg-gui-mailproxy-relaying.png", big=1]
c331641e
DM
303endif::manvolnum[]
304
782f24f4
DC
305These settings are saved to the 'mail' subsection in `/etc/pmg/pmg.conf`. Some of these correspond
306to postfix options in the `main.cf` (see the
307https://www.postfix.org/postconf.5.html[postconf documentation]).
308
309They use the following configuration keys:
e09057ab
DM
310
311include::pmg.mail-relaying-conf-opts.adoc[]
c331641e 312
4a08dffe 313[[pmgconfig_mailproxy_relay_domains]]
c331641e
DM
314Relay Domains
315~~~~~~~~~~~~~
316
c331641e 317ifndef::manvolnum[]
38d14519 318[thumbnail="screenshot/pmg-gui-mailproxy-relaydomains.png", big=1]
c331641e
DM
319endif::manvolnum[]
320
eb269701 321A list of relayed mail domains, that is, what destination domains this
6822b369
DM
322system will relay mail to. The system will reject incoming mails to
323other domains.
c331641e 324
d9c56b22 325
4a08dffe 326[[pmgconfig_mailproxy_ports]]
c331641e
DM
327Ports
328~~~~~
329
c331641e 330ifndef::manvolnum[]
38d14519 331[thumbnail="screenshot/pmg-gui-mailproxy-ports.png", big=1]
c331641e
DM
332endif::manvolnum[]
333
782f24f4
DC
334These settings are saved to the 'mail' subsection in `/etc/pmg/pmg.conf`. Many of these correspond
335to postfix options in the `main.cf` (see the
336https://www.postfix.org/postconf.5.html[postconf documentation]).
337
338They use the following configuration keys:
d9c56b22
DM
339
340include::pmg.mail-ports-conf-opts.adoc[]
341
c331641e 342
4a08dffe 343[[pmgconfig_mailproxy_options]]
c331641e
DM
344Options
345~~~~~~~
346
c331641e 347ifndef::manvolnum[]
38d14519 348[thumbnail="screenshot/pmg-gui-mailproxy-options.png", big=1]
c331641e
DM
349endif::manvolnum[]
350
eb269701 351These settings are saved to the 'mail' subsection in `/etc/pmg/pmg.conf`,
e3d778e0
DM
352using the following configuration keys:
353
354include::pmg.mail-options-conf-opts.adoc[]
c331641e
DM
355
356
89028579
SI
357[[pmgconfig_mailproxy_before_after_queue]]
358Before and After Queue scanning
359~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
360
eb269701 361Email scanning can happen at two different stages of mail-processing:
89028579 362
eb269701 363* Before-queue filtering: During the SMTP session, after the complete message
1824eab9 364 has been received (after the 'DATA' command).
89028579 365
1824eab9
SI
366* After-queue filtering: After initially accepting the mail and putting it on
367 a queue for further processing.
89028579 368
1824eab9
SI
369Before-queue filtering has the advantage that the system can reject a mail (by
370sending a permanent reject code '554'), and leave the task of notifying the
eb269701 371original sender to the other mail server. This is of particular advantage if
1824eab9 372the processed mail is a spam message or contains a virus and has a forged
eb269701 373sender address. Sending out a notification in this situation leads to so-called
89028579 374'backscatter' mail, which might cause your server to get listed as spamming on
3f18659b 375RBLs (Real-time Blackhole List).
89028579 376
1824eab9 377After-queue filtering has the advantage of providing faster delivery of
eb269701
DW
378mails for the sending servers, since queuing emails is much faster than
379analyzing them for spam and viruses.
380
381If a mail is addressed to multiple recipients (for example, when multiple
382addresses are subscribed to the same mailing list), the situation is more
383complicated; your mail server can only reject or accept the mail for all
384recipients, after having received the complete message, while your rule setup
385might accept the mail for part of the recipients and reject it for others. This
386can be due to a complicated rule setup, or if your users use the 'User White-
387and Blacklist' feature.
388
389If the resulting action of the rule system is the same for all recipients, {pmg}
390responds accordingly, if configured for before-queue filtering (sending '554'
89028579 391for a blocked mail and '250' for an accepted or quarantined mail). If some
3f18659b 392mailboxes accept the mail and some reject it, the system has to accept the mail.
89028579
SI
393
394Whether {pmg} notifies the sender that delivery failed for some recipients by
395sending a non-delivery report, depends on the 'ndr_on_block' setting in
eb269701 396'/etc/pmg/pmg.conf'. If enabled, an NDR is sent. Keeping this disabled prevents
89028579 397NDRs being sent to the (possibly forged) sender and thus minimizes the chance
eb269701 398of getting your IP listed on an RBL. However in certain environments, it can be
89028579
SI
399unacceptable not to inform the sender about a rejected mail.
400
eb269701 401The setting has the same effect if after-queue filtering is configured, with
89028579
SI
402the exception that an NDR is always sent out, even if all recipients block the
403mail, since the mail already got accepted before being analyzed.
404
405The details of integrating the mail proxy with {postfix} in both setups are
406explained in {postfix_beforequeue} and {postfix_afterqueue} respectively.
407
89028579 408
d41aa039
SI
409[[pmgconfig_mailproxy_greylisting]]
410Greylisting
411~~~~~~~~~~~
412
413Greylisting is a technique for preventing unwanted messages from reaching the
414resource intensive stages of content analysis (virus detection and spam
eb269701
DW
415detection). By initially replying with a temporary failure code ('450') to
416each new email, {pmg} tells the sending server that it should queue the
417mail and retry delivery at a later point. Since certain kinds of spam get
418sent out by software which has no provisioning for queuing, these mails are
d41aa039
SI
419dropped without reaching {pmg} or your mailbox.
420
421The downside of greylisting is the delay introduced by the initial deferral of
422the email, which usually amounts to less than 30 minutes.
423
424In order to prevent unnecessary delays in delivery from known sources, emails
425coming from a source for a recipient, which have passed greylisting in the
426past are directly passed on: For each email the triple '<sender network,
427sender email, recipient email>' is stored in a list, along with the time when
428delivery was attempted. If an email fits an already existing triple, the
eb269701 429timestamp for that triple is updated, and the email is accepted for further
d41aa039
SI
430processing.
431
eb269701 432As long as a sender and recipient communicate frequently, there is no delay
d41aa039 433introduced by enabling greylisting. A triple is removed after a longer period
eb269701 434of time, if no mail fitting that triple has been seen. The timeouts in {pmg}
d41aa039
SI
435are:
436
437* 2 days for the retry of the first delivery
438
eb269701 439* 36 days for a known triple
d41aa039 440
eb269701 441Mails with an empty envelope sender are always delayed.
d41aa039
SI
442
443Some email service providers send out emails for one domain from multiple
eb269701
DW
444servers. To prevent delays due to an email coming in from two separate IPs of
445the same provider, the triples store a network ('cidr') instead of a single IP.
446For certain large providers, the default network size might be too small. You
d41aa039
SI
447can configure the netmask applied to an IP for the greylist lookup in
448'/etc/pmg/pmg.conf' or in the GUI with the settings 'greylistmask' for IPv4
449and 'greylistmask6' for IPv6 respectively.
450
451
4a08dffe 452[[pmgconfig_mailproxy_transports]]
c331641e
DM
453Transports
454~~~~~~~~~~
455
456ifndef::manvolnum[]
38d14519 457[thumbnail="screenshot/pmg-gui-mailproxy-transports.png", big=1]
c331641e
DM
458endif::manvolnum[]
459
3599cb04 460You can use {pmg} to send emails to different internal email servers. For
eb269701 461example, you can send emails addressed to domain.com to your first email server
3599cb04 462and emails addressed to subdomain.domain.com to a second one.
b335e06b 463
31259590 464You can add the IP addresses, hostname, transport protocol (smtp/lmtp),
3599cb04
TL
465transport ports and mail domains (or just single email addresses) of your
466additional email servers. When transport protocol is set to `lmtp`, the option
eb269701 467'Use MX' is useless and will automatically be set to 'No'.
c331641e
DM
468
469
4a08dffe 470[[pmgconfig_mailproxy_networks]]
c331641e
DM
471Networks
472~~~~~~~~
473
474ifndef::manvolnum[]
38d14519 475[thumbnail="screenshot/pmg-gui-mailproxy-networks.png", big=1]
c331641e
DM
476endif::manvolnum[]
477
3599cb04
TL
478You can add additional internal (trusted) IP networks or hosts. All hosts in
479this list are allowed to relay.
20e879ad 480
eb269701
DW
481NOTE: Hosts in the same subnet as {pmg} can relay by default and don't need to
482be added to this list.
c331641e
DM
483
484
4a08dffe 485[[pmgconfig_mailproxy_tls]]
c331641e
DM
486TLS
487~~~
488
489ifndef::manvolnum[]
38d14519 490[thumbnail="screenshot/pmg-gui-mailproxy-tls.png", big=1]
c331641e
DM
491endif::manvolnum[]
492
3599cb04
TL
493Transport Layer Security (TLS) provides certificate-based authentication and
494encrypted sessions. An encrypted session protects the information that is
495transmitted with SMTP mail. When you activate TLS, {pmg} automatically
496generates a new self signed certificate for you (`/etc/pmg/pmg-tls.pem`).
20e879ad 497
37b2b051 498{pmg} uses opportunistic TLS encryption by default. The SMTP transaction is
20e879ad 499encrypted if the 'STARTTLS' ESMTP feature is supported by the remote
eb269701 500server. Otherwise, messages are sent unencrypted.
91d501f6
SI
501
502You can set a different TLS policy per destination. A destination is either a
eb269701 503remote domain or a next-hop destination, as specified in `/etc/pmg/transport`.
3f18659b 504This can be used if you need to prevent email delivery without
91d501f6
SI
505encryption, or to work around a broken 'STARTTLS' ESMTP implementation. See
506{postfix_tls_readme} for details on the supported policies.
20e879ad 507
374bcb5f
CH
508Additionally, TLS can also be enforced on incoming connections on the external
509port for specific sender domains by creating a TLS inbound domains entry. Mails
510with matching domains must use a encrypted SMTP session, otherwise they are
511rejected. All domains on this list have and entry of
512https://www.postfix.org/postconf.5.html#reject_plaintext_session[`reject_plaintext_session`]
513in a `check_sender_access` table.
514
20e879ad
DM
515Enable TLS logging::
516
eb269701
DW
517To get additional information about SMTP TLS activity, you can enable
518TLS logging. In this case, information about TLS sessions and used
3f18659b 519certificates is logged via syslog.
20e879ad
DM
520
521Add TLS received header::
522
523Set this option to include information about the protocol and cipher
eb269701 524used, as well as the client and issuer CommonName into the "Received:"
20e879ad
DM
525message header.
526
a649b38f
DM
527Those settings are saved to subsection 'mail' in `/etc/pmg/pmg.conf`,
528using the following configuration keys:
529
530include::pmg.mail-tls-conf-opts.adoc[]
531
c331641e 532
20522d96
SI
533[[pmgconfig_mailproxy_dkim]]
534DKIM Signing
535~~~~~~~~~~~~
536
f5fddbff 537ifndef::manvolnum[]
38d14519 538[thumbnail="screenshot/pmg-gui-mailproxy-dkim.png", big=1]
f5fddbff
SI
539endif::manvolnum[]
540
20522d96
SI
541DomainKeys Identified Mail (DKIM) Signatures (see {dkim_rfc}) is a method to
542cryptographically authenticate a mail as originating from a particular domain.
eb269701 543Before sending the mail, a hash over certain header fields and the body is
20522d96
SI
544computed, signed with a private key and added in the `DKIM-Signature` header of
545the mail. The 'selector' (a short identifier chosen by you, used to identify
546which system and private key were used for signing) is also included in the
547`DKIM-Signature` header.
548
eb269701 549The verification is done by the receiver. The public key is fetched
20522d96
SI
550via DNS TXT lookup for `yourselector._domainkey.yourdomain.example` and used
551for verifying the hash. You can publish multiple selectors for your domain,
3f18659b 552each used by a system which sends email from your domain, without the need to
20522d96
SI
553share the private key.
554
555{pmg} verifies DKIM Signatures for inbound mail in the Spam Filter by default.
556
eb269701
DW
557Additionally, it supports conditionally signing outbound mail, if configured.
558It uses one private key and selector per {pmg} deployment (all nodes in a
559cluster use the same key). The key has a minimal size of 1024 bits and
560rsa-sha256 is used as the signing algorithm.
20522d96
SI
561
562The headers included in the signature are taken from the list of
563`Mail::DKIM::Signer`. Additionally `Content-Type` (if present), `From`, `To`,
564`CC`, `Reply-To` and `Subject` get oversigned.
565
566You can either sign all mails received on the internal port using the domain of
3f18659b 567the envelope sender address or create a list of domains, for which emails
20522d96
SI
568should be signed, defaulting to the list of relay domains.
569
570
571Enable DKIM Signing::
572
573Controls whether outbound mail should get DKIM signed.
574
575Selector::
576
577The selector used for signing the mail. The private key used for signing is
3fe91910 578saved under `/etc/pmg/dkim/yourselector.private`. You can display the DNS TXT
20522d96
SI
579record which you need to add to all domains signed by {pmg} by clicking on the
580'View DNS Record' Button.
581
582Sign all Outgoing Mail::
583
584Controls whether all outbound mail should get signed or only mails from domains
eb269701
DW
585listed in `/etc/pmg/dkim/domains`, if it exists and `/etc/pmg/domains`
586otherwise.
20522d96 587
90f38c3d
MS
588Select Signing Domain::
589
590Determines whether to DKIM sign emails using the domain found in the envelope
591from or the from header in the body of the email. The envelope from is also
592known as reverse-path, see {smtp_rfc} section 3.3 and {rfc_5322} section 3.6.2.
593+
594The envelop from of certain emails, bounces for example, can be empty. In these
595cases it is desirable to sign them using the domain found in the from header.
596+
597Additionally, DMARC (see {dmarc_rfc} section 3.1.1) needs the domain found in
598the from header in certain situations.
599
eb269701 600These settings are saved to the 'admin' subsection in `/etc/pmg/pmg.conf`,
20522d96
SI
601using the following configuration keys:
602
603include::pmg.admin-dkim-conf-opts.adoc[]
604
605
61b59f73 606[[pmgconfig_mailproxy_whitelist]]
c331641e
DM
607Whitelist
608~~~~~~~~~
609
610ifndef::manvolnum[]
38d14519 611[thumbnail="screenshot/pmg-gui-mailproxy-whitelist.png", big=1]
c331641e
DM
612endif::manvolnum[]
613
3f18659b 614All SMTP checks are disabled for those entries (e.g. Greylisting,
74ec1f38
ML
615SPF, DNSBL, ...)
616
eb269701 617DNSBL checks are done by `postscreen`, which works on IP addresses and networks.
74ec1f38 618This means it can only make use of the `IP Address` and `IP Network` entries.
6822b369 619
eb269701 620NOTE: If you use a backup MX server (for example, your ISP offers this service
6822b369 621for you) you should always add those servers here.
c331641e 622
74ec1f38
ML
623NOTE: To disable DNSBL checks entirely, remove any `DNSBL Sites` entries in
624xref:pmgconfig_mailproxy_options[Mail Proxy Options].
c331641e 625
4a08dffe 626[[pmgconfig_spamdetector]]
c331641e
DM
627Spam Detector Configuration
628---------------------------
629
2d672352
DM
630Options
631~~~~~~~
632
74bfe8ba 633ifndef::manvolnum[]
38d14519 634[thumbnail="screenshot/pmg-gui-spam-options.png", big=1]
74bfe8ba
DM
635endif::manvolnum[]
636
3371c521
DM
637{pmg} uses a wide variety of local and network tests to identify spam
638signatures. This makes it harder for spammers to identify one aspect
639which they can craft their messages to work around the spam filter.
640
eb269701 641Every single email will be analyzed and have a spam score
3371c521
DM
642assigned. The system attempts to optimize the efficiency of the rules
643that are run in terms of minimizing the number of false positives and
644false negatives.
645
646include::pmg.spam-conf-opts.adoc[]
647
648
4a08dffe 649[[pmgconfig_spamdetector_quarantine]]
2d672352
DM
650Quarantine
651~~~~~~~~~~
3371c521 652
74bfe8ba 653ifndef::manvolnum[]
38d14519 654[thumbnail="screenshot/pmg-gui-spamquar-options.png", big=1]
74bfe8ba
DM
655endif::manvolnum[]
656
3f18659b
OB
657{pmg} analyses all incoming email messages and decides for each
658email if it is ham or spam (or virus). Good emails are delivered to
659the inbox and spam messages are moved into the spam quarantine.
3371c521
DM
660
661The system can be configured to send daily reports to inform users
eb269701 662about personal spam messages received in the last day. The report is
3371c521
DM
663only sent if there are new messages in the quarantine.
664
ee34edb0 665Some options are only available in the config file `/etc/pmg/pmg.conf`,
3f18659b 666and not in the web interface.
ee34edb0 667
3371c521 668include::pmg.spamquar-conf-opts.adoc[]
c331641e
DM
669
670
36b169e6
SI
671[[pmgconfig_spamdetector_customscores]]
672Customization of Rulescores
673~~~~~~~~~~~~~~~~~~~~~~~~~~~
674
f5fddbff 675ifndef::manvolnum[]
38d14519 676[thumbnail="screenshot/pmg-gui-spam-custom-scores.png", big=1]
f5fddbff
SI
677endif::manvolnum[]
678
36b169e6
SI
679While the default scoring of {spamassassin}'s ruleset provides very good
680detection rates, sometimes your particular environment can benefit from
681slightly adjusting the score of a particular rule. Two examples:
682
683* Your system receives spam mails which are scored at 4.9 and you have
684 a rule which puts all mails above 5 in the quarantine. The one thing the
685 spam mails have in common is that they all hit 'URIBL_BLACK'. By increasing
686 the score of this rule by 0.2 points the spam mails would all be quarantined
687 instead of being sent to your users
688
689* Your system tags many legitimate mails from a partner organization as spam,
690 because the organization has a policy that each mail has to start with
691 'Dear madam or sir' (generating 1.9 points through the rule
eb269701 692 'DEAR_SOMETHING'). By setting the score of this rule to 0, you can disable
36b169e6
SI
693 it completely.
694
3f18659b 695The system logs all the rules which a particular mail hits. Analyzing the logs can
36b169e6
SI
696lead to finding such a pattern in your environment.
697
698You can adjust the score of a rule by creating a new 'Custom Rule Score' entry
e1f6d6d0 699in the GUI and entering a {spamassassin} rule as the name.
36b169e6 700
eb269701 701NOTE: In general, it is strongly recommended not to make large changes to the
36b169e6
SI
702default scores.
703
704
4a08dffe 705[[pmgconfig_clamav]]
c331641e
DM
706Virus Detector Configuration
707----------------------------
708
4a08dffe 709[[pmgconfig_clamav_options]]
2d672352
DM
710Options
711~~~~~~~
712
e7c18c7c 713ifndef::manvolnum[]
38d14519 714[thumbnail="screenshot/pmg-gui-virus-options.png", big=1]
e7c18c7c
DM
715endif::manvolnum[]
716
0bfbbf88 717All mails are automatically passed to the included virus detector
3f18659b 718({clamav}). The default settings are considered safe, so it is usually
0bfbbf88
DM
719not required to change them.
720
721{clamav} related settings are saved to subsection 'clamav' in `/etc/pmg/pmg.conf`,
722using the following configuration keys:
723
724include::pmg.clamav-conf-opts.adoc[]
725
e7c18c7c 726ifndef::manvolnum[]
38d14519 727[thumbnail="screenshot/pmg-gui-clamav-database.png", big=1]
e7c18c7c
DM
728endif::manvolnum[]
729
3f18659b
OB
730Please note that the virus signature database is automatically
731updated. You can see the database status in the GUI, and also
eb269701 732trigger manual updates from there.
e7c18c7c 733
0bfbbf88 734
4a08dffe 735[[pmgconfig_clamav_quarantine]]
2d672352
DM
736Quarantine
737~~~~~~~~~~
0bfbbf88 738
e7c18c7c 739ifndef::manvolnum[]
38d14519 740[thumbnail="screenshot/pmg-gui-virusquar-options.png", big=1]
e7c18c7c
DM
741endif::manvolnum[]
742
eb269701
DW
743Identified virus mails are automatically moved to the virus
744quarantine. The administrator can view these mails from the GUI, and
745choose to deliver them, in case of false positives. {pmg} does not notify
0bfbbf88
DM
746individual users about received virus mails.
747
748Virus quarantine related settings are saved to subsection 'virusquar'
749in `/etc/pmg/pmg.conf`, using the following configuration keys:
750
751include::pmg.virusquar-conf-opts.adoc[]
c331641e
DM
752
753
7eff8815
DM
754Custom SpamAssassin configuration
755---------------------------------
756
833e1edc
SI
757This is only for advanced users. {spamassassin}'s rules and their associated
758scores get updated regularly and are trained on a huge corpus, which gets
eb269701 759classified by experts. In most cases, adding a rule for matching a particular
833e1edc
SI
760keyword is the wrong approach, leading to many false positives. Usually bad
761detection rates are better addressed by properly setting up DNS than by adding
762a custom rule - watch out for matches to 'URIBL_BLOCKED' in the logs or
763spam-headers - see the {spamassassin_dnsbl}.
764
eb269701
DW
765To add or change the Proxmox {spamassassin} configuration, log in to the
766console via SSH and change to the `/etc/mail/spamassassin/` directory. In this
d2f49775 767directory there are several files (`init.pre`, `local.cf`, ...) - do not change
69a428d9
SI
768them, as `init.pre`, `v310.pre`, `v320.pre`, `local.cf` will be overwritten by
769the xref:pmgconfig_template_engine[template engine], while the others can
770get updated by any {spamassassin} package upgrade.
833e1edc 771
e1f6d6d0
DW
772To add your custom configuration, you have to create a new file named
773`custom.cf` (in `/etc/mail/spamassassin/`), then add your configuration there.
774Make sure to use the correct {spamassassin_rule_syntax} and test it with:
7eff8815
DM
775
776----
777# spamassassin -D --lint
778----
779
780If you run a cluster, the `custom.cf` file is synchronized from the
d2f49775 781master node to all cluster members automatically.
7eff8815 782
eb269701 783To adjust the score assigned to a particular rule, you
36b169e6
SI
784can also use the xref:pmgconfig_spamdetector_customscores[Custom Rule Score]
785settings in the GUI.
786
7eff8815 787
ed7970d8
SI
788[[pmgconfig_custom_check]]
789Custom Check Interface
790----------------------
791
3f18659b 792For use-cases which are not handled by the {pmg} Virus Detector and
ed7970d8
SI
793{spamassassin} configuration, advanced users can create a custom check
794executable which, if enabled will be called before the Virus Detector and before
3f18659b 795passing an email through the Rule System. The custom check API is kept as
ed7970d8 796simple as possible, while still providing a great deal of control over the
3f18659b 797treatment of an email. Its input is passed via two CLI arguments:
ed7970d8
SI
798
799* the 'api-version' (currently `v1`) - for potential future change of the
800 invocation
801
3f18659b 802* the 'queue-file-name' - a filename, which contains the complete email as
ed7970d8
SI
803 rfc822/eml file
804
eb269701 805The expected output needs to be printed to STDOUT and consists of two lines:
ed7970d8
SI
806
807* the 'api-version' (currently 'v1') - see above
808
809* one of the following 3 results:
eb269701 810** 'OK' - email is OK
3f18659b
OB
811** 'VIRUS: <virusdescription>' - email is treated as if it contained a virus
812 (the virus description is logged and added to the email's headers)
ed7970d8 813** 'SCORE: <number>' - <number> is added (negative numbers are also possible)
3f18659b 814 to the email's spamscore
ed7970d8 815
eb269701 816The check is run with a 5 minute timeout - if this is exceeded, the check
3f18659b 817executable is killed and the email is treated as OK.
ed7970d8
SI
818
819All output written to STDERR by the check is written with priority 'err' to the
820journal/mail.log.
821
eb269701
DW
822Below is a simple sample script following the API (and yielding a random result)
823for reference:
ed7970d8
SI
824
825----
826#!/bin/sh
827
828echo "called with $*" 1>&2
829
830if [ "$#" -ne 2 ]; then
831 echo "usage: $0 APIVERSION QUEUEFILENAME" 1>&2
832 exit 1
833fi
834
835apiver="$1"
836shift
837
838if [ "$apiver" != "v1" ]; then
839 echo "wrong APIVERSION: $apiver" 1>&2
840 exit 2
841fi
842
843queue_file="$1"
844
845echo "v1"
846
847choice=$(shuf -i 0-3 -n1)
848
849case "$choice" in
850 0)
851 echo OK
852 ;;
853 1)
854 echo SCORE: 4
855 ;;
856 2)
857 echo VIRUS: Random Virus
858 ;;
859 3) #timeout-test
860 for i in $(seq 1 7); do
861 echo "custom checking mail: $queue_file - minute $i" 1>&2
862 sleep 60
863 done
864 ;;
865esac
866
867exit 0
868----
869
870The custom check needs to be enabled in the admin section of `/etc/pmg/pmg.conf`
871
872----
873section: admin
874 custom_check 1
875----
876
877The location of the custom check executable can also be set there with the key
878`custom_check_path` and defaults to `/usr/local/bin/pmg-custom-check`.
879
880
c331641e
DM
881User Management
882---------------
883
05336835
DC
884User management in {pmg} consists of three types of users/accounts:
885
886
4a08dffe 887[[pmgconfig_localuser]]
05336835
DC
888Local Users
889~~~~~~~~~~~
890
38d14519 891[thumbnail="screenshot/pmg-gui-local-user-config.png", big=1]
f02d2b90 892
4885bff7
TL
893Local users can manage and audit {pmg}. They can login on the management web
894interface.
05336835 895
a8ac4ab3 896There are four roles:
05336835 897
4885bff7
TL
898Administrator::
899
eb269701 900Is allowed to manage settings of {pmg}, excluding some tasks like network
4885bff7
TL
901configuration and upgrading.
902
903Quarantine manager::
05336835 904
05336835
DC
905Is allowed to manage quarantines, blacklists and whitelists, but not other
906settings. Has no right to view any other data.
907
4885bff7
TL
908Auditor::
909
05336835
DC
910With this role, the user is only allowed to view data and configuration, but
911not to edit it.
912
a8ac4ab3
TL
913Helpdesk::
914
915Combines permissions of the 'Auditor' and the 'Quarantine Manager' role.
916
eb269701 917In addition, there is always the 'root' user, which is used to perform special
4885bff7
TL
918system administrator tasks, such as upgrading a host or changing the network
919configuration.
05336835 920
eb269701
DW
921NOTE: Only PAM users are able to log in via the web interface and ssh, while the
922users created through the web interface are not. Those users are created for
923{pmg} administration only.
05336835
DC
924
925Local user related settings are saved in `/etc/pmg/user.conf`.
926
eb269701 927For details on the fields, see xref:pmg_user_configuration_file[user.conf]
05336835 928
4a08dffe 929[[pmgconfig_ldap]]
05336835
DC
930LDAP/Active Directory
931~~~~~~~~~~~~~~~~~~~~~
932
38d14519 933[thumbnail="screenshot/pmg-gui-ldap-user-config.png", big=1]
f02d2b90 934
fc11986a
DW
935With {pmg}, users can use LDAP and Active directory as authentication methods to
936access their individual xref:pmgadministration_spam_quarantine[Spam Quarantine].
937Additionally, if users have extra email aliases defined in the LDAP directory,
938they will have a single spam quarantine for all of these.
939
940NOTE: Authentication via LDAP must first be enabled using the `Authentication
941mode` (`authmode`) parameter in the
942xref:pmgconfig_spamdetector_quarantine[Spam Detector's Quarantine configuration settings].
943
05336835 944You can specify multiple LDAP/Active Directory profiles, so that you can
fc11986a 945create rules matching particular users and groups.
05336835
DC
946
947Creating a profile requires (at least) the following:
948
fc11986a
DW
949* `Profile Name`: The name assigned to the LDAP profile.
950* `Protocol`: LDAP, LDAPS, or LDAP+STARTTLS (LDAP+STARTTLS is recommended).
951* `Server`: The domain name/IP address of the LDAP server. A fallback can also
952 be configured using the second field.
953* `User name`: The Bind DN for authentication on the LDAP server.
954 This is required if your server does not support anonymous binds.
955* `Password`: Password for the Bind DN user.
956* `Base DN`: The directory which users are searched under.
05336835
DC
957
958All other fields should work with the defaults for most setups, but can be
959used to customize the queries.
960
fc11986a 961The settings are saved to `/etc/pmg/ldap.conf`. Details about the options
05336835
DC
962can be found here: xref:pmg_ldap_configuration_file[ldap.conf]
963
964Bind user
965^^^^^^^^^
966
967It is highly recommended that the user which you use for connecting to the
eb269701 968LDAP server only has permission to query the server. For LDAP servers
05336835 969(for example OpenLDAP or FreeIPA), the username has to be of a format like
eb269701
DW
970'uid=username,cn=users,cn=accounts,dc=domain', where the specific fields
971depend on your setup. For Active Directory servers, the format should be
fc11986a 972'username@domain' or 'domain\username'.
05336835
DC
973
974Sync
975^^^^
976
eb269701
DW
977{pmg} synchronizes the relevant user and group information periodically, so that
978the information is quickly available, even when the LDAP/AD server is
979temporarily inaccessible.
05336835 980
3f18659b 981After a successful sync, the groups and users should be visible on the web
eb269701 982interface. Following this, you can create rules targeting LDAP users and groups.
c331641e
DM
983
984
4a08dffe 985[[pmgconfig_fetchmail]]
8538d9a2 986Fetchmail
05336835
DC
987~~~~~~~~~
988
38d14519 989[thumbnail="screenshot/pmg-gui-fetchmail-config.png", big=1]
f02d2b90 990
eb269701 991Fetchmail is a utility for polling and forwarding emails. You can define
3f18659b 992email accounts, which will then be fetched and forwarded to the email
05336835
DC
993address you defined.
994
995You have to add an entry for each account/target combination you want to
eb269701 996fetch and forward. These will then be regularly polled and forwarded,
05336835
DC
997according to your configuration.
998
eb269701 999The API and web interface offer the following configuration options:
8538d9a2
DM
1000
1001include::fetchmail.conf.5-opts.adoc[]
1002
a4f14219
TL
1003[[user_tfa_auth]]
1004Two-Factor Authentication
1005-------------------------
1006
1007Users of the admin interface can configure two-factor authentication to
1008increase protection of their accounts.
1009
1a4f8407
TL
1010NOTE: Joining a cluster with two-factor authentication enabled for the `root`
1011user is not supported. Remove the second factor when joining the cluster.
f8dc6aec 1012
a4f14219
TL
1013Available Second Factors
1014~~~~~~~~~~~~~~~~~~~~~~~~
1015
1016You can set up multiple second factors, in order to avoid a situation in which
1017losing your smartphone or security key locks you out of your account
1018permanently.
1019
c4f5ee14 1020The following two-factor authentication methods are available:
a4f14219
TL
1021
1022* User configured TOTP
1023 (https://en.wikipedia.org/wiki/Time-based_One-Time_Password[Time-based One-Time Password]).
1024 A short code derived from a shared secret and the current time, it changes
1025 every 30 seconds.
1026* WebAuthn (https://en.wikipedia.org/wiki/WebAuthn[Web Authentication]).
1027 A general standard for authentication. It is implemented by various security
1028 devices, like hardware keys or trusted platform modules (TPM) from a computer
1029 or smart phone.
1030* Single use Recovery Keys. A list of keys which should either be
1031 printed out and locked in a secure place or saved digitally in an electronic
1032 vault. Each key can be used only once. These are perfect for ensuring that
1033 you are not locked out, even if all of your other second factors are lost or
1034 corrupt.
1035
1036Configuration of Two-Factor
1037~~~~~~~~~~~~~~~~~~~~~~~~~~~
1038
1039Users can choose to enable 'TOTP' or 'WebAuthn' as a second factor on login,
c4f5ee14 1040via the 'TFA' button in the user list.
a4f14219
TL
1041
1042Users can always add and use one time 'Recovery Keys'.
1043
1044//[thumbnail="screenshot/gui-datacenter-two-factor.png"]//TODO
1045
1046[[user_tfa_setup_totp]]
1047=== TOTP
1048
1049//[thumbnail="screenshot/pve-gui-tfa-add-totp.png"]//TODO
1050
1051There is no server setup required. Simply install a TOTP app on your
1052smartphone (for example, https://github.com/andOTP/andOTP#downloads[andOTP])
1053and use the Proxmox Backup Server web-interface to add a TOTP factor.
1054
1055After opening the 'TOTP' window, the user is presented with a dialog to set up
1056'TOTP' authentication. The 'Secret' field contains the key, which can be
1057randomly generated via the 'Randomize' button. An optional 'Issuer Name' can be
1058added to provide information to the 'TOTP' app about what the key belongs to.
1059Most 'TOTP' apps will show the issuer name together with the corresponding
1060'OTP' values. The username is also included in the QR code for the 'TOTP' app.
1061
1062After generating a key, a QR code will be displayed, which can be used with most
1063OTP apps such as FreeOTP. The user then needs to verify the current user
1064password (unless logged in as 'root'), as well as the ability to correctly use
1065the 'TOTP' key, by typing the current 'OTP' value into the 'Verification Code'
1066field and pressing the 'Apply' button.
1067
1068
1069[[user_tfa_setup_webauthn]]
1070=== WebAuthn
1071
1072For WebAuthn to work, you need to have two things:
1073
1074* A trusted HTTPS certificate (for example, by using
c4f5ee14 1075 xref:sysadmin_certs_get_trusted_acme_cert[Let's Encrypt]).
a4f14219
TL
1076 While it probably works with an untrusted certificate, some browsers may
1077 warn or refuse WebAuthn operations if it is not trusted.
1078* Setup the WebAuthn configuration (see *User Management -> Two Factor ->
1079 WebAuthn* in the {pmg} web interface). This can be
1080 auto-filled in most setups.
1081
1082Once you have fulfilled both of these requirements, you can add a WebAuthn
1083configuration in the *Two Factor* panel under *Datacenter -> Permissions -> Two
1084Factor*.
1085
1086[[user_tfa_setup_recovery_keys]]
1087=== Recovery Keys
1088
1089//[thumbnail="screenshot/pve-gui-tfa-add-recovery-keys.png"]//TODO
1090
1091Recovery key codes do not need any preparation; you can simply create a
1092set of recovery keys in the *Two Factor* panel under *Datacenter -> Permissions
1093-> Two Factor*.
1094
1095NOTE: There can only be one set of single-use recovery keys per user at any
1096time.
1097
1098WebAuthn Configuration
1099~~~~~~~~~~~~~~~~~~~~~~
1100
1101//[thumbnail="screenshot/gui-datacenter-webauthn-edit.png"]//TODO
1102
1103To allow users to use 'WebAuthn' authentication, it is necessaary to use a valid
1104domain with a valid SSL certificate, otherwise some browsers may warn or refuse
1105to authenticate altogether.
1106
1107NOTE: Changing the 'WebAuthn' configuration may render all existing 'WebAuthn'
1108registrations unusable!
1109
1110You can configure WebAuthn directly in the 'Two Factor' panel, there's an
1111auto-fill button that will set the correct values for most setups.
8538d9a2 1112
e62ceaf0
DM
1113ifdef::manvolnum[]
1114include::pmg-copyright.adoc[]
1115endif::manvolnum[]