Hetzner - DokuWiki
DebianMailserver3
Seldon (Diskussion | Beiträge) (→Postfix) |
|||
(19 dazwischenliegende Versionen von 3 Benutzern werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
Ein Leitfaden für die Einrichtung eines Mailservers unter Debian Sarge und Etch. | Ein Leitfaden für die Einrichtung eines Mailservers unter Debian Sarge und Etch. | ||
− | Genutzt werden Postfix und Cyrus IMAPd (POP). | + | Genutzt werden [http://www.postfix.org/ Postfix] und [http://cyrusimap.web.cmu.edu/ Cyrus] IMAPd (POP). |
− | Die Benutzer werden mittels PAM gegen eine MySQL Datenbank verifiziert. | + | Die Benutzer werden mittels PAM gegen eine MySQL Datenbank verifiziert. |
− | Zur einfachen Administration erweist sich WebCyrAdm (PHP) als nützlich. | + | Zur einfachen Administration erweist sich [http://www.web-cyradm.org/ WebCyrAdm] (PHP) als nützlich. |
− | + | Zur Mailfilterung wird [http://spamassassin.apache.org/ SpamAssassin], [http://postgrey.schweikert.ch/ Postgrey] und [http://www.clamav.net/ ClamAV] (Antivirus) eingesetzt. | |
− | + | Ein HTTPD, sowie PHP und MySQL sollte bereits eingerichtet sein. | |
+ | |||
+ | == libpam-mysql == | ||
~$ apt-get install libpam-mysql | ~$ apt-get install libpam-mysql | ||
Zeile 14: | Zeile 16: | ||
~$ nano /etc/pam.d/imap | ~$ nano /etc/pam.d/imap | ||
− | Inhalt von /etc/pam.d/imap | + | Inhalt von '''/etc/pam.d/imap''': |
− | auth sufficient pam_mysql.so user= | + | auth sufficient pam_mysql.so user=<DB_USER> passwd=<DB_PASSWD> \ |
host=127.0.0.1 db=mail table=accountuser usercolumn=username \ | host=127.0.0.1 db=mail table=accountuser usercolumn=username \ | ||
passwdcolumn=password crypt=1 logtable=log logmsgcolumn=msg \ | passwdcolumn=password crypt=1 logtable=log logmsgcolumn=msg \ | ||
logusercolumn=user loghostcolumn=host logpidcolumn=pid \ | logusercolumn=user loghostcolumn=host logpidcolumn=pid \ | ||
logtimecolumn=time | logtimecolumn=time | ||
− | + | ||
− | account required pam_mysql.so user= | + | account required pam_mysql.so user=<DB_USER> passwd=<DB_PASSWD> \ |
host=127.0.0.1 db=mail table=accountuser usercolumn=username \ | host=127.0.0.1 db=mail table=accountuser usercolumn=username \ | ||
passwdcolumn=password crypt=1 logtable=log logmsgcolumn=msg \ | passwdcolumn=password crypt=1 logtable=log logmsgcolumn=msg \ | ||
Zeile 30: | Zeile 32: | ||
Wir ändern die Dateirechte von "imap" via chmod auf 600. | Wir ändern die Dateirechte von "imap" via chmod auf 600. | ||
− | + | Anschließend SymLinks auf pop, smtp und sieve anlegen: | |
− | Anschließend SymLinks auf pop, smtp und sieve anlegen | + | |
~$ ln -s /etc/pam.d/imap /etc/pam.d/pop | ~$ ln -s /etc/pam.d/imap /etc/pam.d/pop | ||
Zeile 37: | Zeile 38: | ||
~$ ln -s /etc/pam.d/imap /etc/pam.d/sieve | ~$ ln -s /etc/pam.d/imap /etc/pam.d/sieve | ||
− | + | == Cyrus SASL == | |
~$ apt-get install libsasl2 libsasl2-modules sasl2-bin | ~$ apt-get install libsasl2 libsasl2-modules sasl2-bin | ||
− | + | ||
~$ nano /etc/default/saslauthd | ~$ nano /etc/default/saslauthd | ||
− | + | "#START=yes" kommentieren wir aus. Nach einem Reboot wird der Daemon folgend automatisch gestartet. | |
+ | |||
+ | START=yes | ||
SMTP-AUTH ermöglichen. | SMTP-AUTH ermöglichen. | ||
Zeile 54: | Zeile 57: | ||
mech_list: PLAIN LOGIN | mech_list: PLAIN LOGIN | ||
− | + | Anm.: evtl. kann dieser Schritt erst nach der Installation von postfix (nächster Schritt) ausgeführt werden. | |
− | Debian Sarge | + | == Postfix == |
+ | |||
+ | '''Debian Sarge:''' | ||
~$ apt-get install openssl postfix postfix-mysql postfix-tls postfix-pcre | ~$ apt-get install openssl postfix postfix-mysql postfix-tls postfix-pcre | ||
− | Debian Etch | + | '''Debian Etch:''' |
~$ apt-get install openssl postfix postfix-mysql postfix-pcre | ~$ apt-get install openssl postfix postfix-mysql postfix-pcre | ||
Zeile 66: | Zeile 71: | ||
Evtl. Nachfragen von APT bez. der Konfiguration von Postfix werden verneint. Die Konfigurationsdateien werden manuell angelegt. | Evtl. Nachfragen von APT bez. der Konfiguration von Postfix werden verneint. Die Konfigurationsdateien werden manuell angelegt. | ||
− | Der Benutzer postfix muss der Gruppe sasl angehören. Sonst funktioniert SMTP-AUTH nicht | + | Der Benutzer postfix muss der Gruppe sasl angehören. Sonst funktioniert SMTP-AUTH nicht: |
~$ adduser postfix sasl | ~$ adduser postfix sasl | ||
Zeile 76: | Zeile 81: | ||
# the user name and password to log into the mysql server | # the user name and password to log into the mysql server | ||
hosts = 127.0.0.1 | hosts = 127.0.0.1 | ||
− | user = | + | user = <i><DB_USER></i> |
− | password = | + | password = <i><DB_PASSWD></i> |
# the database name on the servers | # the database name on the servers | ||
− | dbname = | + | dbname = <i><DB_NAME></i> |
# the table name | # the table name | ||
table = virtual | table = virtual | ||
Zeile 87: | Zeile 92: | ||
# Return the first match only | # Return the first match only | ||
additional_conditions = and status = '1' limit 1 | additional_conditions = and status = '1' limit 1 | ||
+ | # For Postfix 2.2 and later The SQL query template. | ||
+ | query= SELECT alias FROM virtual WHERE username LIKE '%s' and status = '1' limit 1 | ||
~$ nano /etc/postfix/mysql-mydestination.cf | ~$ nano /etc/postfix/mysql-mydestination.cf | ||
Zeile 92: | Zeile 99: | ||
# the user name and password to log into the mysql server | # the user name and password to log into the mysql server | ||
hosts = 127.0.0.1 | hosts = 127.0.0.1 | ||
− | user = | + | user = <i><DB_USER></i> |
− | password = | + | password = <i><DB_PASSWD></i> |
# the database name on the servers | # the database name on the servers | ||
− | dbname = | + | dbname = <i><DB_NAME></i> |
# the table name | # the table name | ||
table = domain | table = domain | ||
Zeile 101: | Zeile 108: | ||
select_field = domain_name | select_field = domain_name | ||
where_field = domain_name | where_field = domain_name | ||
+ | # For Postfix 2.2 and later The SQL query template. | ||
+ | query= SELECT domain_name FROM domain WHERE domain_name='%s' | ||
~$ nano /etc/postfix/mysql-virtual.cf | ~$ nano /etc/postfix/mysql-virtual.cf | ||
Zeile 106: | Zeile 115: | ||
# the user name and password to log into the mysql server | # the user name and password to log into the mysql server | ||
hosts = 127.0.0.1 | hosts = 127.0.0.1 | ||
− | user = | + | user = <i><DB_USER></i> |
− | password = | + | password = <i><DB_PASSWD></i> |
# the database name on the servers | # the database name on the servers | ||
− | dbname = | + | dbname = <i><DB_NAME></i> |
# the table name | # the table name | ||
table = virtual | table = virtual | ||
Zeile 116: | Zeile 125: | ||
where_field = alias | where_field = alias | ||
additional_conditions = and status = '1' | additional_conditions = and status = '1' | ||
+ | # For Postfix 2.2 and later The SQL query template. | ||
+ | query=SELECT dest FROM virtual WHERE alias='%s' and status = '1' | ||
− | Hierbei bitte nicht vergessen, für <DB_USER>, <DB_PASSWD> und <DB_NAME> die korrekten Werte einzusetzen. | + | Hierbei bitte nicht vergessen, für <DB_USER>, <DB_PASSWD> und <DB_NAME> die korrekten Werte einzusetzen. |
− | + | Konfiguration von Postfix '''master.cf''': | |
− | + | ||
~$ nano /etc/postfix/master.cf | ~$ nano /etc/postfix/master.cf | ||
− | Aus | + | Aus... |
smtp inet n - - - - smtpd | smtp inet n - - - - smtpd | ||
− | #smtps inet n - - - - | + | #smtps inet n - - - - |
− | + | smtpd -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o | |
− | + | smtpd_client_restrictions=permit_sasl_authenticated,reject | |
− | wird ... | + | wird... |
smtp inet n - n - - smtpd | smtp inet n - n - - smtpd | ||
− | smtps inet n - n - - | + | smtps inet n - n - - |
− | + | smtpd -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o | |
− | + | smtpd_client_restrictions=permit_sasl_authenticated,reject | |
Dadurch wird Postfix aus dem chroot Gefängnis befreit. Wir ersparen uns Zeit und Nerven, entsprechend MySQL und SASL anzupassen. | Dadurch wird Postfix aus dem chroot Gefängnis befreit. Wir ersparen uns Zeit und Nerven, entsprechend MySQL und SASL anzupassen. | ||
− | + | Weiterhin modifizieren (Debian Sarge) bzw. ergänzen (Debian Etch) die '''master.cf''' um folgenden Eintrag, damit Cyrus seinen Dienst verrichtet: | |
− | Weiterhin modifizieren (Debian Sarge) bzw. ergänzen (Debian Etch) die master.cf um folgenden Eintrag, damit Cyrus seinen Dienst verrichtet | + | |
cyrus unix - n n - - pipe | cyrus unix - n n - - pipe | ||
− | + | flags= user=cyrus argv=/usr/sbin/cyrdeliver -r ${sender} -m ${extension} ${user} | |
− | + | ||
− | + | ||
− | + | ||
− | Beispiel ... | + | Konfiguration von Postfix '''main.cf''': |
+ | Beispiel... | ||
# | # | ||
# general | # general | ||
# | # | ||
− | mydomain = | + | mydomain = domain.tld |
− | myorigin = $mydomain | + | #myorigin = /etc/mailname |
− | mydestination = mysql:/etc/postfix/mysql-mydestination.cf | + | myorigin = mail.$mydomain |
+ | mydestination = localhost, localhost.$mydomain, $mydomain, mail.$mydomain, mysql:/etc/postfix/mysql-mydestination.cf | ||
+ | #virtual_mailbox_domains = mysql:/etc/postfix/mysql-mydestination.cf | ||
+ | #mydestination = mysql:/etc/postfix/mysql-mydestination.cf | ||
mynetworks = 127.0.0.0/8 | mynetworks = 127.0.0.0/8 | ||
relay_domains = | relay_domains = | ||
Zeile 162: | Zeile 172: | ||
sender_canonical_maps = mysql:/etc/postfix/mysql-canonical.cf | sender_canonical_maps = mysql:/etc/postfix/mysql-canonical.cf | ||
alias_maps = $alias_database | alias_maps = $alias_database | ||
+ | smtp_host_lookup = native,dns | ||
# | # | ||
# sasl auth | # sasl auth | ||
Zeile 174: | Zeile 185: | ||
strict_rfc821_envelopes = yes | strict_rfc821_envelopes = yes | ||
smtpd_sender_restrictions = | smtpd_sender_restrictions = | ||
− | + | permit_sasl_authenticated, | |
− | + | permit_mynetworks, | |
− | + | reject_non_fqdn_sender, | |
− | + | reject_unknown_sender_domain, | |
− | + | permit | |
smtpd_recipient_restrictions = | smtpd_recipient_restrictions = | ||
− | + | reject_invalid_hostname, | |
− | + | reject_non_fqdn_hostname, | |
− | + | reject_non_fqdn_sender, | |
− | + | reject_non_fqdn_recipient, | |
− | + | reject_unknown_sender_domain, | |
− | + | reject_unknown_recipient_domain, | |
− | + | reject_unauth_pipelining, | |
− | + | permit_sasl_authenticated, | |
− | + | permit_mynetworks, | |
− | + | reject_unauth_destination, | |
− | + | reject_rbl_client zen.spamhaus.org, | |
− | + | reject_rbl_client bl.spamcop.net, | |
− | + | reject_rbl_client list.dsbl.org, | |
+ | reject_rbl_client sbl-xbl.spamhaus.org, | ||
+ | reject_rbl_client whois.rfc-ignorant.org, | ||
+ | reject_rbl_client ix.dnsbl.manitu.org, | ||
+ | reject_rbl_client multihop.dsbl.org, | ||
+ | reject_rbl_client dnsbl.ahbl.org, | ||
+ | reject_rbl_client rhsbl.ahbl.org, | ||
+ | permit | ||
smtpd_data_restrictions = | smtpd_data_restrictions = | ||
− | + | reject_unauth_pipelining, | |
− | + | permit | |
# | # | ||
# SASL TLS | # SASL TLS | ||
Zeile 208: | Zeile 226: | ||
smtpd_sasl_local_domain = | smtpd_sasl_local_domain = | ||
smtpd_sasl_auth_only = yes | smtpd_sasl_auth_only = yes | ||
+ | #smtpd_tls_auth_only = yes | ||
smtpd_tls_note_starttls_offer = yes | smtpd_tls_note_starttls_offer = yes | ||
smtpd_tls_cert_file = /etc/ssl/certs/smtps.pem | smtpd_tls_cert_file = /etc/ssl/certs/smtps.pem | ||
Zeile 216: | Zeile 235: | ||
smtpd_tls_session_cache_timeout = 3600s | smtpd_tls_session_cache_timeout = 3600s | ||
tls_random_source = dev:/dev/urandom | tls_random_source = dev:/dev/urandom | ||
+ | relayhost = | ||
+ | |||
+ | '''Hinweis:''' Um Fehler vorzubeugen, sollte nach der Konfiguration noch | ||
− | |||
-$ newaliases | -$ newaliases | ||
+ | |||
ausgeführt werden. | ausgeführt werden. | ||
− | + | == Cyrus == | |
− | Debian Sarge | + | '''Debian Sarge''': |
~$ apt-get install cyrus21-common cyrus21-admin cyrus21-imapd cyrus21-pop3d cyrus21-clients | ~$ apt-get install cyrus21-common cyrus21-admin cyrus21-imapd cyrus21-pop3d cyrus21-clients | ||
− | Debian Etch (sowohl Cyrus 2.1 als auch 2.2 verfügbar!) | + | '''Debian Etch''' (sowohl Cyrus 2.1 als auch 2.2 verfügbar!): |
~$ apt-get install cyrus-common-2.2 cyrus-admin-2.2 cyrus-imapd-2.2 cyrus-pop3d-2.2 cyrus-clients-2.2 | ~$ apt-get install cyrus-common-2.2 cyrus-admin-2.2 cyrus-imapd-2.2 cyrus-pop3d-2.2 cyrus-clients-2.2 | ||
− | ''' | + | Konfiguration von '''/etc/imapd.conf''' |
− | Folgende Einträge gilt es sicherzustellen ... | + | Folgende Einträge gilt es sicherzustellen... |
unixhierarchysep: yes | unixhierarchysep: yes | ||
Zeile 241: | Zeile 263: | ||
#sasl_auxprop_plugin: | #sasl_auxprop_plugin: | ||
− | Unterstützung für IMAPs(ecure) und POPs(ecure) via SSL | + | Unterstützung für IMAPs(ecure) und POPs(ecure) via SSL: |
# File containing the global certificate used for ALL services (imap, pop3, | # File containing the global certificate used for ALL services (imap, pop3, | ||
Zeile 251: | Zeile 273: | ||
tls_ca_file: /etc/ssl/certs/cyrus.pem | tls_ca_file: /etc/ssl/certs/cyrus.pem | ||
+ | Konfiguration von '''/etc/cyrus.conf''' | ||
− | + | Wir überprüfen... | |
− | |||
− | |||
imap cmd="imapd -U 30" listen="imap" prefork=0 maxchild=100 | imap cmd="imapd -U 30" listen="imap" prefork=0 maxchild=100 | ||
imaps cmd="imapd -s -U 30" listen="imaps" prefork=0 maxchild=100 | imaps cmd="imapd -s -U 30" listen="imaps" prefork=0 maxchild=100 | ||
Zeile 264: | Zeile 285: | ||
Bitte nicht einfach Copy 'n Paste, sondern die jeweiligen, unter Umständen schon vorhandenen Einträge in der Datei suchen und mit diesen Einträgen vergleichen, bzw. die Kommentare entfernen! | Bitte nicht einfach Copy 'n Paste, sondern die jeweiligen, unter Umständen schon vorhandenen Einträge in der Datei suchen und mit diesen Einträgen vergleichen, bzw. die Kommentare entfernen! | ||
− | + | Damit Autenfizierung via SASL/libpam-mysql/MySQL funktioniert müssen wir den SASL Benutzer 'cyrus' anlegen: | |
− | Damit Autenfizierung via SASL/libpam-mysql/MySQL funktioniert müssen wir den SASL Benutzer 'cyrus' anlegen | + | |
~$ saslpasswd2 -c cyrus | ~$ saslpasswd2 -c cyrus | ||
− | Passwort für den 'cyrus' merken, wir brauchen es nochmal für WebCyradm! | + | Passwort für den ''cyrus'' merken, wir brauchen es nochmal für WebCyradm! |
− | ==== SSL Zertifikate für Postfix (SMTPs), Cyrus IMAPs & POPs, erzeugen | + | == Postgrey == |
+ | |||
+ | apt-get install postgrey | ||
+ | |||
+ | Nun ändern wir in '''/etc/defaults/postgrey''' diese Zeile: | ||
+ | POSTGREY_OPTS="--inet=127.0.0.1:60000" | ||
+ | |||
+ | in | ||
+ | POSTGREY_OPTS="--inet=127.0.0.1:60000 --delay=60 --auto-whitelist-clients=2 --max-age=365" | ||
+ | |||
+ | Dadurch werden nach 2 erfolgreichen Zustellungen im zeitraum von 365 Tagen automatisch der entsprechende Mailserver in die whitelist übernommen. Delay=60 bewirkt das der jeweilige Server für 60sekunden auf die greylist kommt. Ich setze das deshalb so da wir einige Kunden haben mit denen wir nur 1-2 mal im Jahr kontakt haben. Ist der Zeitraum für den cache zu niedrig würden diese nie whitelisted werden. | ||
+ | |||
+ | Jetzt noch in '''/etc/postfix/main.cf''' bei ''smtpd_recipient_restrictions ='' folgendes mit anfügen (falls noch nicht vorhanden): | ||
+ | check_policy_service inet:127.0.0.1:60000 | ||
+ | |||
+ | Nun sicherstellen das postgrey auch läuft: | ||
+ | /etc/init.d/postgrey restart | ||
+ | |||
+ | == ClamAV == | ||
+ | |||
+ | Mittels apt-get installieren: | ||
+ | apt-get install clamav clamav-base clamav-daemon clamav-freshclam | ||
+ | |||
+ | In '''/etc/postfix/main.cf''' folgende Zeilen hinzufügen: | ||
+ | # | ||
+ | # ClamAV Antivirus | ||
+ | # | ||
+ | content_filter = scan:127.0.0.1:10026 | ||
+ | receive_override_options = no_address_mappings | ||
+ | |||
+ | In '''/etc/postfix/master.cf''' folgende Zeilen hinzufügen: | ||
+ | # Antivirus | ||
+ | # AV scan filter (used by content_filter) | ||
+ | scan unix - - n - 16 smtp | ||
+ | -o smtp_send_xforward_command=yes | ||
+ | # For injecting mail back into postfix from the filter | ||
+ | 127.0.0.1:10025 inet n - n - 16 smtpd | ||
+ | -o content_filter= | ||
+ | -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks | ||
+ | -o smtpd_helo_restrictions= | ||
+ | -o smtpd_client_restrictions= | ||
+ | -o smtpd_sender_restrictions= | ||
+ | -o smtpd_recipient_restrictions=permit_mynetworks,reject | ||
+ | -o mynetworks_style=host | ||
+ | -o smtpd_authorized_xforward_hosts=127.0.0.0/8 | ||
+ | |||
+ | == SpamAssassin == | ||
+ | |||
+ | Installieren via apt-get: | ||
+ | |||
+ | apt-get install spamassassin | ||
+ | |||
+ | In der Datei '''/etc/defaults/spamassassin''' überprüfen ob | ||
+ | |||
+ | ENABLED=1 | ||
+ | |||
+ | nicht auskommentiert ist, damit spamassassin mit '''/etc/init.d/spamassassin''' gestartet werden kann | ||
+ | |||
+ | Die Integration von SpamAssassin in Postfix wurde schon weiter oben vorgenommen, hier noch einmal zum überprüfen: | ||
+ | |||
+ | '''/etc/postfix/master.cf''' editieren | ||
+ | Aus... | ||
+ | smtp inet n - n - - smtpd | ||
+ | smtps inet n - n - - | ||
+ | smtpd -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o | ||
+ | smtpd_client_restrictions=permit_sasl_authenticated,reject | ||
+ | |||
+ | |||
+ | Wird... | ||
+ | smtp inet n - n - - smtpd | ||
+ | -o content_filter=spamassassin | ||
+ | smtps inet n - n - - smtpd | ||
+ | -o content_filter=spamassassin | ||
+ | -o smtpd_tls_wrappermode=yes | ||
+ | -o smtpd_sasl_auth_enable=yes | ||
+ | -o smtpd_client_restrictions=permit_sasl_authenticated,reject | ||
+ | |||
+ | Diese Zeilen am Ende hinzufügen: | ||
+ | # Spamassassin | ||
+ | spamassassin unix - n n - - pipe | ||
+ | user=nobody argv=/usr/bin/spamc -f -e | ||
+ | /usr/sbin/sendmail -oi -f ${sender} ${recipient} | ||
+ | |||
+ | Ein Anpassung von '''/etc/spamassassin/local.cf''' ist zwar vorteilhaft, jedoch nicht unbedingt notwendig. | ||
+ | |||
+ | Hier eine Beispielkonfiguration: | ||
+ | |||
+ | # Add *****SPAM***** to the Subject header of spam e-mails | ||
+ | # | ||
+ | rewrite_header Subject *****SPAM***** | ||
+ | add_header spam Flag _YESNOCAPS_ | ||
+ | add_header all Status _YESNO_, score=_SCORE_ required=_REQD_ tests=_TESTS_ autolearn=_AUTOLEARN_ version=_VERSION_ | ||
+ | add_header all Level _STARS(*)_ | ||
+ | add_header all Score _SCORE_ | ||
+ | add_header all Checker-Version SpamAssassin _VERSION_ (_SUBVERSION_) on _HOSTNAME_ | ||
+ | |||
+ | # Save spam messages as a message/rfc822 MIME attachment instead of | ||
+ | # modifying the original message (0: off, 2: use text/plain instead) | ||
+ | # | ||
+ | report_safe 1 | ||
+ | # Set the threshold at which a message is considered spam (default: 5.0) | ||
+ | required_score 4.8 | ||
+ | # Use Bayesian classifier (default: 1) | ||
+ | use_bayes 1 | ||
+ | # Bayesian classifier auto-learning (default: 1) | ||
+ | bayes_auto_learn 1 | ||
+ | |||
+ | bayes_path /etc/spamassassin/bayes | ||
+ | #bayes_use_chi2_combining 1 | ||
+ | bayes_auto_expire 0 | ||
+ | bayes_journal_max_size 15000000 | ||
+ | bayes_expiry_max_db_size 20000000 | ||
+ | |||
+ | # Set headers which may provide inappropriate cues to the Bayesian | ||
+ | # classifier | ||
+ | # | ||
+ | # bayes_ignore_header X-Bogosity | ||
+ | # bayes_ignore_header X-Spam-Flag | ||
+ | # bayes_ignore_header X-Spam-Status | ||
+ | bayes_ignore_header Return-Path | ||
+ | bayes_ignore_header Received | ||
+ | bayes_ignore_header X-Spam-Flag | ||
+ | bayes_ignore_header X-Spam-Status | ||
+ | bayes_ignore_header X-Spam-Flag | ||
+ | bayes_ignore_header X-Spam-Level | ||
+ | bayes_ignore_header X-purgate | ||
+ | bayes_ignore_header X-purgate-ID | ||
+ | bayes_ignore_header X-purgate-Ad | ||
+ | bayes_ignore_header X-GMX-Antispam | ||
+ | bayes_ignore_header X-Resent-For | ||
+ | bayes_ignore_header X-Resent-By | ||
+ | bayes_ignore_header X-Resent-To | ||
+ | bayes_ignore_header Resent-To | ||
+ | bayes_ignore_header Sender | ||
+ | bayes_ignore_header Precedence | ||
+ | bayes_ignore_header X-Antispam | ||
+ | bayes_ignore_header X-Sieve | ||
+ | bayes_ignore_header X-Spamcount | ||
+ | bayes_ignore_header X-Spamsensitivity | ||
+ | bayes_ignore_header To | ||
+ | bayes_ignore_header X-Sieve | ||
+ | # Blacklisting | ||
+ | # blacklist_from | ||
+ | |||
+ | == SSL Zertifikate für Postfix (SMTPs), Cyrus IMAPs & POPs, erzeugen == | ||
~$ cd /etc/ssl/certs/ | ~$ cd /etc/ssl/certs/ | ||
~$ openssl req -new -x509 -keyout smtps.pem -out smtps.pem -days 365 -nodes | ~$ openssl req -new -x509 -keyout smtps.pem -out smtps.pem -days 365 -nodes | ||
+ | ~$ chgrp postfix smtps.pem | ||
~$ cp smtps.pem cyrus.pem | ~$ cp smtps.pem cyrus.pem | ||
~$ chown cyrus:mail cyrus.pem | ~$ chown cyrus:mail cyrus.pem | ||
− | + | ~$ chmod 640 smtps.pem cyrus.pem | |
'''Ganz wichtig:''' | '''Ganz wichtig:''' | ||
− | + | ||
Common Name (eg, YOUR name) []: SERVERNAME.TLD | Common Name (eg, YOUR name) []: SERVERNAME.TLD | ||
Übrige Daten für das selbstsignierte Zertifikat sind beliebig. | Übrige Daten für das selbstsignierte Zertifikat sind beliebig. | ||
− | + | == WebCyradm installieren und konfigurieren == | |
Folgender Snapshot ist als stabil zu bewerten, ältere Versionen sollten nicht mehr eingesetzt werden. | Folgender Snapshot ist als stabil zu bewerten, ältere Versionen sollten nicht mehr eingesetzt werden. | ||
− | + | Voraussetzungen: PHP IMAP, PHP PEAR DB, PHP safe_mode off (!) | |
+ | |||
+ | '''Hinweis:''' Bei neu installiertem PHP PEAR nicht vergessen, | ||
− | |||
~$ pear install DB | ~$ pear install DB | ||
+ | |||
auszuführen. | auszuführen. | ||
~$ wget http://www.web-cyradm.org/web-cyradm-svn-0.5.5.tar.gz | ~$ wget http://www.web-cyradm.org/web-cyradm-svn-0.5.5.tar.gz | ||
− | ... entpacken und bearbeiten von scripts/insertuser_mysql.sql | + | ... entpacken (z.B. nach /var/www/) und bearbeiten von '''scripts/insertuser_mysql.sql''' |
− | Im ersten Statement (DB) 'User' und (DB) 'Password' setzen. | + | Im ersten Statement (DB) 'User' und (DB) 'Password' setzen. Der User darf nicht "cyrus" heissen (s.u.). |
Im zweiten Statement Name der Datenbank 'Db' und Datenbank-Benutzer 'User' angeben. | Im zweiten Statement Name der Datenbank 'Db' und Datenbank-Benutzer 'User' angeben. | ||
Zeile 305: | Zeile 472: | ||
Es folgt: | Es folgt: | ||
− | ~$ mysql -u root -p | + | ~$ mysql -u root -p < insertuser_mysql.sql |
Anpassen von scripts/create_mysql.sql | Anpassen von scripts/create_mysql.sql | ||
Zeile 316: | Zeile 483: | ||
Anschließend: | Anschließend: | ||
− | ~$ mysql -u root -p DB_NAME | + | ~$ mysql -u root -p DB_NAME < create_mysql.sql |
− | Modifizieren von config/conf.php.dist und speichern als /config/conf.php | + | Modifizieren von config/conf.php.dist und speichern als /config/conf.php Dateirechte sollten via chmod auf 600 beschränkt werden (chmod 600 conf.php). |
− | Dateirechte sollten via chmod auf 600 beschränkt werden (chmod 600 conf.php). | + | |
# The Cyrus login stuff | # The Cyrus login stuff | ||
$CYRUS = array( | $CYRUS = array( | ||
− | 'HOST' = | + | 'HOST' => 'localhost', |
− | 'PORT' = | + | 'PORT' => 143, |
− | 'ADMIN' = | + | 'ADMIN' => 'cyrus', |
− | 'PASS' = | + | 'PASS' => 'PASSWORT_VON_USER_CYRUS!!!' |
); | ); | ||
# | # | ||
$DB = array( | $DB = array( | ||
− | 'TYPE' = | + | 'TYPE' => 'mysql', |
− | 'USER' = | + | 'USER' => 'DB_USER', |
− | 'PASS' = | + | 'PASS' => 'DB_PASSWORD', |
− | 'PROTO' = | + | 'PROTO' => 'unix', // set to "tcp" for TCP/IP |
− | 'HOST' = | + | 'HOST' => 'localhost', |
− | 'NAME' = | + | 'NAME' => 'DB_NAME' |
); | ); | ||
# | # | ||
Zeile 345: | Zeile 511: | ||
$DOMAIN_AS_PREFIX = 1; | $DOMAIN_AS_PREFIX = 1; | ||
− | Das Logfile anlegen und Rechte anpassen ... | + | Das Logfile anlegen und Rechte anpassen... |
− | ~$ touch /var/log/web- | + | ~$ touch /var/log/web-cyradm-login.log |
~$ chown www-data:www-data /var/log/web-cyradm-login.log | ~$ chown www-data:www-data /var/log/web-cyradm-login.log | ||
− | + | == Testen des Systems == | |
− | Wir starten beteiligte Dienste neu | + | Wir starten beteiligte Dienste neu: |
− | ~$ /etc/init.d/cyrus21 restart (respektive cyrus2.2) | + | ~$ /etc/init.d/clamav restart |
+ | ~$ /etc/init.d/postgrey restart | ||
+ | ~$ /etc/init.d/spamassassin restart | ||
+ | ~$ /etc/init.d/cyrus21 restart (respektive /etc/init.d/cyrus2.2 restart) | ||
~$ /etc/init.d/saslauthd restart | ~$ /etc/init.d/saslauthd restart | ||
~$ /etc/init.d/postfix restart | ~$ /etc/init.d/postfix restart | ||
− | Benutzer Cyrus kann sich einloggen ? | + | Alternativ: |
+ | |||
+ | /etc/init.d/clamav-daemon restart | ||
+ | |||
+ | Benutzer Cyrus kann sich einloggen? | ||
~$ cyradm --user cyrus --server localhost --auth plain | ~$ cyradm --user cyrus --server localhost --auth plain | ||
~$ Password: ist_schnuppe_user_cyrus_hat_kein_postfach | ~$ Password: ist_schnuppe_user_cyrus_hat_kein_postfach | ||
− | ~$ IMAP Password: | + | ~$ IMAP Password: <Passwort_vom_Benutzer_Cyrus> |
~$ quit | ~$ quit | ||
Zeile 383: | Zeile 556: | ||
~$ 250-8BITMIME | ~$ 250-8BITMIME | ||
~$ 250 DSN | ~$ 250 DSN | ||
− | ~$ '''MAIL FROM: | + | ~$ '''MAIL FROM: <huhu@huhu.de>''' |
~$ 250 2.1.0 Ok | ~$ 250 2.1.0 Ok | ||
− | ~$ '''RCPT TO: | + | ~$ '''RCPT TO: <huhu@huhu.de>''' |
~$ 250 2.1.5 Ok | ~$ 250 2.1.5 Ok | ||
~$ '''DATA''' | ~$ '''DATA''' | ||
− | ~$ 354 End data with | + | ~$ 354 End data with <CR><LF>.<CR><LF> |
− | ~$ '''TEST BLABLA''' | + | ~$ '''TEST BLABLA''' |
~$ '''.''' | ~$ '''.''' | ||
~$ 250 2.0.0 Ok: queued as ED913AD0159 | ~$ 250 2.0.0 Ok: queued as ED913AD0159 | ||
Zeile 395: | Zeile 568: | ||
~$ 221 2.0.0 Bye | ~$ 221 2.0.0 Bye | ||
~$ Connection closed by foreign host. | ~$ Connection closed by foreign host. | ||
+ | |||
+ | Falls "smtpd_tls_auth_only = yes" in '''/etc/postfix/main.cf''' gesetzt ist, funktioniert das Beispiel nicht, da Postfix dann zuerst eine TLS Verbindung erwartet. | ||
Hakt es irgendwo: Ein Blick in die LOG Daten - auth.log, syslog, mail.log, mysql.log et cetera - hilft immer. | Hakt es irgendwo: Ein Blick in die LOG Daten - auth.log, syslog, mail.log, mysql.log et cetera - hilft immer. | ||
--[[Benutzer:Seldon|Seldon]] 09:33, 20. Mai 2007 (CEST) | --[[Benutzer:Seldon|Seldon]] 09:33, 20. Mai 2007 (CEST) | ||
+ | |||
+ | --[[Benutzer:Pwoelfel|pwoelfel]] 17:00, 15. Jänner 2008: Aktualisierung der Postfix mysql config, Erweiterung um SpamAssassin, Postgrey und ClamAV | ||
+ | |||
+ | [[Kategorie:Dedizierte Server]] | ||
+ | [[Kategorie:Betriebssysteme]] | ||
+ | [[Kategorie:Debian]] |
Aktuelle Version vom 24. Februar 2012, 09:02 Uhr
Ein Leitfaden für die Einrichtung eines Mailservers unter Debian Sarge und Etch. Genutzt werden Postfix und Cyrus IMAPd (POP).
Die Benutzer werden mittels PAM gegen eine MySQL Datenbank verifiziert.
Zur einfachen Administration erweist sich WebCyrAdm (PHP) als nützlich.
Zur Mailfilterung wird SpamAssassin, Postgrey und ClamAV (Antivirus) eingesetzt.
Ein HTTPD, sowie PHP und MySQL sollte bereits eingerichtet sein.
Inhaltsverzeichnis |
libpam-mysql
~$ apt-get install libpam-mysql
~$ nano /etc/pam.d/imap
Inhalt von /etc/pam.d/imap:
auth sufficient pam_mysql.so user=<DB_USER> passwd=<DB_PASSWD> \ host=127.0.0.1 db=mail table=accountuser usercolumn=username \ passwdcolumn=password crypt=1 logtable=log logmsgcolumn=msg \ logusercolumn=user loghostcolumn=host logpidcolumn=pid \ logtimecolumn=time account required pam_mysql.so user=<DB_USER> passwd=<DB_PASSWD> \ host=127.0.0.1 db=mail table=accountuser usercolumn=username \ passwdcolumn=password crypt=1 logtable=log logmsgcolumn=msg \ logusercolumn=user loghostcolumn=host logpidcolumn=pid \ logtimecolumn=time
Wir ändern die Dateirechte von "imap" via chmod auf 600.
Anschließend SymLinks auf pop, smtp und sieve anlegen:
~$ ln -s /etc/pam.d/imap /etc/pam.d/pop ~$ ln -s /etc/pam.d/imap /etc/pam.d/smtp ~$ ln -s /etc/pam.d/imap /etc/pam.d/sieve
Cyrus SASL
~$ apt-get install libsasl2 libsasl2-modules sasl2-bin ~$ nano /etc/default/saslauthd
"#START=yes" kommentieren wir aus. Nach einem Reboot wird der Daemon folgend automatisch gestartet.
START=yes
SMTP-AUTH ermöglichen.
~$ nano /etc/postfix/sasl/smtpd.conf
In diese Datei eintragen:
pwcheck_method: saslauthd mech_list: PLAIN LOGIN
Anm.: evtl. kann dieser Schritt erst nach der Installation von postfix (nächster Schritt) ausgeführt werden.
Postfix
Debian Sarge:
~$ apt-get install openssl postfix postfix-mysql postfix-tls postfix-pcre
Debian Etch:
~$ apt-get install openssl postfix postfix-mysql postfix-pcre
Evtl. Nachfragen von APT bez. der Konfiguration von Postfix werden verneint. Die Konfigurationsdateien werden manuell angelegt.
Der Benutzer postfix muss der Gruppe sasl angehören. Sonst funktioniert SMTP-AUTH nicht:
~$ adduser postfix sasl
Bearbeiten der Konfigurationsdateien. Jene Dateien sollten abschließend via chmod 600 in ihren Zugriffsberechtigungen abgesichert werden (chmod 600 mysql*.cf).
~$ nano /etc/postfix/mysql-canonical.cf
# the user name and password to log into the mysql server hosts = 127.0.0.1 user = <i><DB_USER></i> password = <i><DB_PASSWD></i> # the database name on the servers dbname = <i><DB_NAME></i> # the table name table = virtual # select_field = alias where_field = username # Return the first match only additional_conditions = and status = '1' limit 1 # For Postfix 2.2 and later The SQL query template. query= SELECT alias FROM virtual WHERE username LIKE '%s' and status = '1' limit 1
~$ nano /etc/postfix/mysql-mydestination.cf
# the user name and password to log into the mysql server hosts = 127.0.0.1 user = <i><DB_USER></i> password = <i><DB_PASSWD></i> # the database name on the servers dbname = <i><DB_NAME></i> # the table name table = domain # select_field = domain_name where_field = domain_name # For Postfix 2.2 and later The SQL query template. query= SELECT domain_name FROM domain WHERE domain_name='%s'
~$ nano /etc/postfix/mysql-virtual.cf
# the user name and password to log into the mysql server hosts = 127.0.0.1 user = <i><DB_USER></i> password = <i><DB_PASSWD></i> # the database name on the servers dbname = <i><DB_NAME></i> # the table name table = virtual # select_field = dest where_field = alias additional_conditions = and status = '1' # For Postfix 2.2 and later The SQL query template. query=SELECT dest FROM virtual WHERE alias='%s' and status = '1'
Hierbei bitte nicht vergessen, für <DB_USER>, <DB_PASSWD> und <DB_NAME> die korrekten Werte einzusetzen.
Konfiguration von Postfix master.cf:
~$ nano /etc/postfix/master.cf
Aus...
smtp inet n - - - - smtpd #smtps inet n - - - - smtpd -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject
wird...
smtp inet n - n - - smtpd smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject
Dadurch wird Postfix aus dem chroot Gefängnis befreit. Wir ersparen uns Zeit und Nerven, entsprechend MySQL und SASL anzupassen. Weiterhin modifizieren (Debian Sarge) bzw. ergänzen (Debian Etch) die master.cf um folgenden Eintrag, damit Cyrus seinen Dienst verrichtet:
cyrus unix - n n - - pipe flags= user=cyrus argv=/usr/sbin/cyrdeliver -r ${sender} -m ${extension} ${user}
Konfiguration von Postfix main.cf: Beispiel...
# # general # mydomain = domain.tld #myorigin = /etc/mailname myorigin = mail.$mydomain mydestination = localhost, localhost.$mydomain, $mydomain, mail.$mydomain, mysql:/etc/postfix/mysql-mydestination.cf #virtual_mailbox_domains = mysql:/etc/postfix/mysql-mydestination.cf #mydestination = mysql:/etc/postfix/mysql-mydestination.cf mynetworks = 127.0.0.0/8 relay_domains = mailbox_transport = cyrus virtual_alias_maps = mysql:/etc/postfix/mysql-virtual.cf sender_canonical_maps = mysql:/etc/postfix/mysql-canonical.cf alias_maps = $alias_database smtp_host_lookup = native,dns # # sasl auth # for clients # smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_delay_reject = yes smtpd_helo_required = yes disable_vrfy_command = yes strict_rfc821_envelopes = yes smtpd_sender_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_non_fqdn_sender, reject_unknown_sender_domain, permit smtpd_recipient_restrictions = reject_invalid_hostname, reject_non_fqdn_hostname, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_unauth_pipelining, permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination, reject_rbl_client zen.spamhaus.org, reject_rbl_client bl.spamcop.net, reject_rbl_client list.dsbl.org, reject_rbl_client sbl-xbl.spamhaus.org, reject_rbl_client whois.rfc-ignorant.org, reject_rbl_client ix.dnsbl.manitu.org, reject_rbl_client multihop.dsbl.org, reject_rbl_client dnsbl.ahbl.org, reject_rbl_client rhsbl.ahbl.org, permit smtpd_data_restrictions = reject_unauth_pipelining, permit # # SASL TLS # for server # smtp_use_tls = yes # # SASL TLS # for clients # smtpd_use_tls = yes smtpd_sasl_local_domain = smtpd_sasl_auth_only = yes #smtpd_tls_auth_only = yes smtpd_tls_note_starttls_offer = yes smtpd_tls_cert_file = /etc/ssl/certs/smtps.pem smtpd_tls_key_file = /etc/ssl/certs/smtps.pem smtpd_tls_CAfile = /etc/ssl/certs/smtps.pem smtpd_tls_loglevel = 1 smtpd_tls_received_header = yes smtpd_tls_session_cache_timeout = 3600s tls_random_source = dev:/dev/urandom relayhost =
Hinweis: Um Fehler vorzubeugen, sollte nach der Konfiguration noch
-$ newaliases
ausgeführt werden.
Cyrus
Debian Sarge:
~$ apt-get install cyrus21-common cyrus21-admin cyrus21-imapd cyrus21-pop3d cyrus21-clients
Debian Etch (sowohl Cyrus 2.1 als auch 2.2 verfügbar!):
~$ apt-get install cyrus-common-2.2 cyrus-admin-2.2 cyrus-imapd-2.2 cyrus-pop3d-2.2 cyrus-clients-2.2
Konfiguration von /etc/imapd.conf
Folgende Einträge gilt es sicherzustellen...
unixhierarchysep: yes admins: cyrus sasl_mech_list: PLAIN sasl_pwcheck_method: saslauthd #sasl_auxprop_plugin:
Unterstützung für IMAPs(ecure) und POPs(ecure) via SSL:
# File containing the global certificate used for ALL services (imap, pop3, # lmtp, sieve) tls_cert_file: /etc/ssl/certs/cyrus.pem # File containing the private key belonging to the global server # certificate. tls_key_file: /etc/ssl/certs/cyrus.pem # File containing one or more Certificate Authority (CA) certificates. tls_ca_file: /etc/ssl/certs/cyrus.pem
Konfiguration von /etc/cyrus.conf
Wir überprüfen...
imap cmd="imapd -U 30" listen="imap" prefork=0 maxchild=100 imaps cmd="imapd -s -U 30" listen="imaps" prefork=0 maxchild=100 pop3 cmd="pop3d -U 30" listen="pop3" prefork=0 maxchild=50 pop3s cmd="pop3d -s -U 30" listen="pop3s" prefork=0 maxchild=50 squatter_1 cmd="/usr/bin/nice -n 19 /usr/sbin/squatter -s" period=120
Bitte nicht einfach Copy 'n Paste, sondern die jeweiligen, unter Umständen schon vorhandenen Einträge in der Datei suchen und mit diesen Einträgen vergleichen, bzw. die Kommentare entfernen!
Damit Autenfizierung via SASL/libpam-mysql/MySQL funktioniert müssen wir den SASL Benutzer 'cyrus' anlegen:
~$ saslpasswd2 -c cyrus
Passwort für den cyrus merken, wir brauchen es nochmal für WebCyradm!
Postgrey
apt-get install postgrey
Nun ändern wir in /etc/defaults/postgrey diese Zeile:
POSTGREY_OPTS="--inet=127.0.0.1:60000"
in
POSTGREY_OPTS="--inet=127.0.0.1:60000 --delay=60 --auto-whitelist-clients=2 --max-age=365"
Dadurch werden nach 2 erfolgreichen Zustellungen im zeitraum von 365 Tagen automatisch der entsprechende Mailserver in die whitelist übernommen. Delay=60 bewirkt das der jeweilige Server für 60sekunden auf die greylist kommt. Ich setze das deshalb so da wir einige Kunden haben mit denen wir nur 1-2 mal im Jahr kontakt haben. Ist der Zeitraum für den cache zu niedrig würden diese nie whitelisted werden.
Jetzt noch in /etc/postfix/main.cf bei smtpd_recipient_restrictions = folgendes mit anfügen (falls noch nicht vorhanden):
check_policy_service inet:127.0.0.1:60000
Nun sicherstellen das postgrey auch läuft:
/etc/init.d/postgrey restart
ClamAV
Mittels apt-get installieren:
apt-get install clamav clamav-base clamav-daemon clamav-freshclam
In /etc/postfix/main.cf folgende Zeilen hinzufügen:
# # ClamAV Antivirus # content_filter = scan:127.0.0.1:10026 receive_override_options = no_address_mappings
In /etc/postfix/master.cf folgende Zeilen hinzufügen:
# Antivirus # AV scan filter (used by content_filter) scan unix - - n - 16 smtp -o smtp_send_xforward_command=yes # For injecting mail back into postfix from the filter 127.0.0.1:10025 inet n - n - 16 smtpd -o content_filter= -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks -o smtpd_helo_restrictions= -o smtpd_client_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o mynetworks_style=host -o smtpd_authorized_xforward_hosts=127.0.0.0/8
SpamAssassin
Installieren via apt-get:
apt-get install spamassassin
In der Datei /etc/defaults/spamassassin überprüfen ob
ENABLED=1
nicht auskommentiert ist, damit spamassassin mit /etc/init.d/spamassassin gestartet werden kann
Die Integration von SpamAssassin in Postfix wurde schon weiter oben vorgenommen, hier noch einmal zum überprüfen:
/etc/postfix/master.cf editieren Aus...
smtp inet n - n - - smtpd smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject
Wird...
smtp inet n - n - - smtpd -o content_filter=spamassassin smtps inet n - n - - smtpd -o content_filter=spamassassin -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject
Diese Zeilen am Ende hinzufügen:
# Spamassassin spamassassin unix - n n - - pipe user=nobody argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
Ein Anpassung von /etc/spamassassin/local.cf ist zwar vorteilhaft, jedoch nicht unbedingt notwendig.
Hier eine Beispielkonfiguration:
# Add *****SPAM***** to the Subject header of spam e-mails # rewrite_header Subject *****SPAM***** add_header spam Flag _YESNOCAPS_ add_header all Status _YESNO_, score=_SCORE_ required=_REQD_ tests=_TESTS_ autolearn=_AUTOLEARN_ version=_VERSION_ add_header all Level _STARS(*)_ add_header all Score _SCORE_ add_header all Checker-Version SpamAssassin _VERSION_ (_SUBVERSION_) on _HOSTNAME_
# Save spam messages as a message/rfc822 MIME attachment instead of # modifying the original message (0: off, 2: use text/plain instead) # report_safe 1 # Set the threshold at which a message is considered spam (default: 5.0) required_score 4.8 # Use Bayesian classifier (default: 1) use_bayes 1 # Bayesian classifier auto-learning (default: 1) bayes_auto_learn 1
bayes_path /etc/spamassassin/bayes #bayes_use_chi2_combining 1 bayes_auto_expire 0 bayes_journal_max_size 15000000 bayes_expiry_max_db_size 20000000
# Set headers which may provide inappropriate cues to the Bayesian # classifier # # bayes_ignore_header X-Bogosity # bayes_ignore_header X-Spam-Flag # bayes_ignore_header X-Spam-Status bayes_ignore_header Return-Path bayes_ignore_header Received bayes_ignore_header X-Spam-Flag bayes_ignore_header X-Spam-Status bayes_ignore_header X-Spam-Flag bayes_ignore_header X-Spam-Level bayes_ignore_header X-purgate bayes_ignore_header X-purgate-ID bayes_ignore_header X-purgate-Ad bayes_ignore_header X-GMX-Antispam bayes_ignore_header X-Resent-For bayes_ignore_header X-Resent-By bayes_ignore_header X-Resent-To bayes_ignore_header Resent-To bayes_ignore_header Sender bayes_ignore_header Precedence bayes_ignore_header X-Antispam bayes_ignore_header X-Sieve bayes_ignore_header X-Spamcount bayes_ignore_header X-Spamsensitivity bayes_ignore_header To bayes_ignore_header X-Sieve # Blacklisting # blacklist_from
SSL Zertifikate für Postfix (SMTPs), Cyrus IMAPs & POPs, erzeugen
~$ cd /etc/ssl/certs/ ~$ openssl req -new -x509 -keyout smtps.pem -out smtps.pem -days 365 -nodes ~$ chgrp postfix smtps.pem ~$ cp smtps.pem cyrus.pem ~$ chown cyrus:mail cyrus.pem ~$ chmod 640 smtps.pem cyrus.pem
Ganz wichtig:
Common Name (eg, YOUR name) []: SERVERNAME.TLD
Übrige Daten für das selbstsignierte Zertifikat sind beliebig.
WebCyradm installieren und konfigurieren
Folgender Snapshot ist als stabil zu bewerten, ältere Versionen sollten nicht mehr eingesetzt werden.
Voraussetzungen: PHP IMAP, PHP PEAR DB, PHP safe_mode off (!)
Hinweis: Bei neu installiertem PHP PEAR nicht vergessen,
~$ pear install DB
auszuführen.
~$ wget http://www.web-cyradm.org/web-cyradm-svn-0.5.5.tar.gz
... entpacken (z.B. nach /var/www/) und bearbeiten von scripts/insertuser_mysql.sql
Im ersten Statement (DB) 'User' und (DB) 'Password' setzen. Der User darf nicht "cyrus" heissen (s.u.).
Im zweiten Statement Name der Datenbank 'Db' und Datenbank-Benutzer 'User' angeben.
Es folgt:
~$ mysql -u root -p < insertuser_mysql.sql
Anpassen von scripts/create_mysql.sql
INSERT INTO adminuser (username, password) VALUES ('USERNAME_WEBCRYADM', ENCRYPT('PASSWORD')); INSERT INTO domainadmin (domain_name,adminuser) VALUES ('*','USERNAME_WEBCRYADM'); INSERT INTO accountuser (username, password) VALUES ('cyrus', ENCRYPT('PASSWORT_VON_USER_CYRUS!!!')); INSERT INTO `settings` ( `username` , `style` , `maxdisplay` , `warnlevel` ) VALUES ( 'USERNAME_WEBCRYADM', 'default', '15', '90');
Anschließend:
~$ mysql -u root -p DB_NAME < create_mysql.sql
Modifizieren von config/conf.php.dist und speichern als /config/conf.php Dateirechte sollten via chmod auf 600 beschränkt werden (chmod 600 conf.php).
# The Cyrus login stuff $CYRUS = array( 'HOST' => 'localhost', 'PORT' => 143, 'ADMIN' => 'cyrus', 'PASS' => 'PASSWORT_VON_USER_CYRUS!!!' ); # $DB = array( 'TYPE' => 'mysql', 'USER' => 'DB_USER', 'PASS' => 'DB_PASSWORD', 'PROTO' => 'unix', // set to "tcp" for TCP/IP 'HOST' => 'localhost', 'NAME' => 'DB_NAME' ); # # Where should web-cyradm write its log to? $LOG_DIR = "/var/log"; # $CRYPT = "crypt"; # $DOMAIN_AS_PREFIX = 1;
Das Logfile anlegen und Rechte anpassen...
~$ touch /var/log/web-cyradm-login.log ~$ chown www-data:www-data /var/log/web-cyradm-login.log
Testen des Systems
Wir starten beteiligte Dienste neu:
~$ /etc/init.d/clamav restart ~$ /etc/init.d/postgrey restart ~$ /etc/init.d/spamassassin restart ~$ /etc/init.d/cyrus21 restart (respektive /etc/init.d/cyrus2.2 restart) ~$ /etc/init.d/saslauthd restart ~$ /etc/init.d/postfix restart
Alternativ:
/etc/init.d/clamav-daemon restart
Benutzer Cyrus kann sich einloggen?
~$ cyradm --user cyrus --server localhost --auth plain ~$ Password: ist_schnuppe_user_cyrus_hat_kein_postfach ~$ IMAP Password: <Passwort_vom_Benutzer_Cyrus> ~$ quit
Postfix/SMTP Zugang klappt?
~$ telnet localhost 25 ~$ Trying 127.0.0.1... ~$ Connected to nostromo. ~$ Escape character is '^]'. ~$ 220 nostromo.soellner.info ESMTP Postfix ~$ EHLO huhu.de ~$ 250-nostromo.soellner.info ~$ 250-PIPELINING ~$ 250-SIZE 10240000 ~$ 250-ETRN ~$ 250-STARTTLS ~$ 250-AUTH LOGIN PLAIN ~$ 250-AUTH=LOGIN PLAIN ~$ 250-ENHANCEDSTATUSCODES ~$ 250-8BITMIME ~$ 250 DSN ~$ MAIL FROM: <huhu@huhu.de> ~$ 250 2.1.0 Ok ~$ RCPT TO: <huhu@huhu.de> ~$ 250 2.1.5 Ok ~$ DATA ~$ 354 End data with <CR><LF>.<CR><LF> ~$ TEST BLABLA ~$ . ~$ 250 2.0.0 Ok: queued as ED913AD0159 ~$ QUIT ~$ 221 2.0.0 Bye ~$ Connection closed by foreign host.
Falls "smtpd_tls_auth_only = yes" in /etc/postfix/main.cf gesetzt ist, funktioniert das Beispiel nicht, da Postfix dann zuerst eine TLS Verbindung erwartet.
Hakt es irgendwo: Ein Blick in die LOG Daten - auth.log, syslog, mail.log, mysql.log et cetera - hilft immer.
--Seldon 09:33, 20. Mai 2007 (CEST)
--pwoelfel 17:00, 15. Jänner 2008: Aktualisierung der Postfix mysql config, Erweiterung um SpamAssassin, Postgrey und ClamAV