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