Benutzer-Werkzeuge

Webseiten-Werkzeuge


postfix_test

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
postfix_test [2025/10/18 10:26]
jango
postfix_test [2025/10/24 13:01] (aktuell)
jango
Zeile 1: Zeile 1:
-=====Version 1=====+Beispiele für [[Postfix]] Setups mit [[SASL]] für [[PAM]], [[LDAP]] etc. 
 + 
 +=====SASL mit PAM=====
  
 Ubuntu 24.04 Ubuntu 24.04
Zeile 5: Zeile 7:
 <code bash> <code bash>
 # Postfix und LibSASL installieren # Postfix und LibSASL installieren
-sudo apt install postfix libsasl2-modules sasl2-bin+sudo apt install -y postfix libsasl2-modules sasl2-bin
  
-# SASL gegen PAM (lokale User)+# SASL soll gegen PAM authentifizieren. (lokale User)
 sudo sed -i 's/^START=.*/START=yes/' /etc/default/saslauthd sudo sed -i 's/^START=.*/START=yes/' /etc/default/saslauthd
 sudo sed -i 's/^MECHANISMS=.*/MECHANISMS="pam"/' /etc/default/saslauthd sudo sed -i 's/^MECHANISMS=.*/MECHANISMS="pam"/' /etc/default/saslauthd
 +
 sudo systemctl enable --now saslauthd sudo systemctl enable --now saslauthd
 sudo systemctl status saslauthd sudo systemctl status saslauthd
 +
 +# Postfix user muss in die SASL Gruppe!
 sudo adduser postfix sasl sudo adduser postfix sasl
  
-# SASL für Postfix+# SASL Konfiguration für Postfix erstellen
 sudo mkdir -p /etc/postfix/sasl sudo mkdir -p /etc/postfix/sasl
 sudo tee /etc/postfix/sasl/smtpd.conf >/dev/null <<'EOF' sudo tee /etc/postfix/sasl/smtpd.conf >/dev/null <<'EOF'
Zeile 22: Zeile 27:
 EOF EOF
  
- +# SASL serverseitig einschalten
-# SASL einschalten (Server-Seite)+
 sudo postconf -e "smtpd_sasl_auth_enable = yes" sudo postconf -e "smtpd_sasl_auth_enable = yes"
 sudo postconf -e "smtpd_sasl_type = cyrus" sudo postconf -e "smtpd_sasl_type = cyrus"
Zeile 29: Zeile 33:
 sudo postconf -e "broken_sasl_auth_clients = yes" sudo postconf -e "broken_sasl_auth_clients = yes"
  
-# WICHTIG: Keine TLS-Pflicht für AUTH (sonst gäbe es ohne Zertifikat kein AUTH)+# WICHTIG: Keine TLS-Pflicht für AUTH (sonst ohne Zertifikat kein AUTH)
 sudo postconf -e "smtpd_tls_auth_only = no" sudo postconf -e "smtpd_tls_auth_only = no"
 sudo postconf -e "smtpd_use_tls = no" sudo postconf -e "smtpd_use_tls = no"
Zeile 37: Zeile 41:
 sudo postconf -e "smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination" sudo postconf -e "smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination"
  
-Optional wie auf smtp02:+Relay Host konfigurieren. Kein AUTH! Postfix dürfen am Exchange anonym senden. Evtl aendern. 
 sudo postconf -e "relayhost = vie-srv-ex02.d2000.local" sudo postconf -e "relayhost = vie-srv-ex02.d2000.local"
 #sudo postconf -e "fallback_relay = vie-srv-ex01.d2000.local" #sudo postconf -e "fallback_relay = vie-srv-ex01.d2000.local"
  
-# master.cf smtpd Socket NICHT im Chroot!! 2 x n +# proxy-protocol konfigurieren
-smtp      inet  n                               smtpd +
-  -o smtpd_sasl_auth_enable=yes +
- +
-# proxy-protocol+
 sudo postconf -e "smtpd_upstream_proxy_protocol = haproxy" sudo postconf -e "smtpd_upstream_proxy_protocol = haproxy"
 sudo postconf -e "smtpd_upstream_proxy_timeout = 5s" sudo postconf -e "smtpd_upstream_proxy_timeout = 5s"
 sudo postconf -e "postscreen_upstream_proxy_protocol = haproxy" sudo postconf -e "postscreen_upstream_proxy_protocol = haproxy"
 sudo postconf -e "postscreen_upstream_proxy_timeout = 5s" sudo postconf -e "postscreen_upstream_proxy_timeout = 5s"
 +
 +cat <<EOF
 +### Add this to master.cf and dont forget to add users!
 +
 +smtp      inet  n                               smtpd
 +  -o smtpd_sasl_auth_enable=yes
 +  -o smtpd_upstream_proxy_protocol=haproxy
 +127.0.0.1:2525 inet n  -  n  -  -  smtpd
 +  -o smtpd_upstream_proxy_protocol=
 +EOF
 +</code>
 +
 +=====SASL mit AD=====
 +
 +Die Datei /etc/saslauthd.conf fehlt im ursprünglichen Walkthrough weil sie nur benötigt wird wenn saslauthd mit einem Mechanismus arbeitet der eine eigene Konfiguration braucht – wie z. B. ldap für AD-Authentifizierung.
 +
 +Im ursprünglichen Setup wird MECHANISMS="pam" verwendet. Das bedeutet:
 +
 +  - saslauthd delegiert die Authentifizierung an PAM
 +  - PAM wiederum nutzt lokale Systemuser oder andere Module (z. B. pam_unix, pam_winbind, etc.)
 +  - Die Konfiguration erfolgt dann über /etc/pam.d/ – nicht über eine eigene saslauthd.conf
 +
 +Kein Bedarf für /etc/saslauthd.conf.
 +
 +Sobald du MECHANISMS="ldap" oder rimap oder shadow oder andere Mechanismen verwendest, muss saslauthd wissen, wie es sich mit dem Zielsystem verbindet. 
 +
 +<code>
 +sudo sed -i 's/^MECHANISMS=.*/MECHANISMS="ldap"/' /etc/default/saslauthd
 +</code>
 +
 +<code>
 +sudo nano /etc/saslauthd.conf
 +</code>
 +
 +<code>
 +ldap_servers: ldap://dc01.d2000.local
 +ldap_search_base: dc=d2000,dc=local
 +ldap_bind_dn: cn=ldap-reader,cn=Users,dc=d2000,dc=local
 +ldap_bind_pw: DEIN_PASSWORT
 +ldap_filter: (sAMAccountName=%u)
 +ldap_auth_method: bind
 +</code>
 +
 +=====Alma Linux=====
 +
 +<code bash>
 +# Postfix und LibSASL installieren
 +sudo dnf install postfix cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain
 +
 +# SASL soll gegen PAM authentifizieren. (lokale User)
 +sudo sed -i 's/^MECH=.*/MECH=pam/' /etc/sysconfig/saslauthd
 +
 +sudo systemctl enable --now saslauthd
 +sudo systemctl status saslauthd
 +
 +sudo groupadd sasl
 +sudo usermod -a -G sasl postfix
 +sudo systemctl restart saslauthd
 +
 +sudo mkdir -p /etc/postfix/sasl
 +sudo tee /etc/postfix/sasl/smtpd.conf >/dev/null <<'EOF'
 +pwcheck_method: saslauthd
 +mech_list: PLAIN LOGIN
 +log_level: 7
 +EOF
 +
 +sudo postconf -e "smtpd_sasl_auth_enable = yes"
 +sudo postconf -e "smtpd_sasl_type = cyrus"
 +sudo postconf -e "smtpd_sasl_path = smtpd"
 +sudo postconf -e "smtpd_sasl_security_options = noanonymous"
 +sudo postconf -e "broken_sasl_auth_clients = yes"
 +
 +sudo postconf -e "smtpd_tls_auth_only = no"
 +sudo postconf -e "smtpd_use_tls = no"
 +sudo postconf -e "smtpd_tls_security_level = none"
 +
 +sudo postconf -e "smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination"
 +
 +sudo postconf -e "relayhost = vie-srv-ex02.d2000.local"
 +sudo postconf -e "fallback_relay = vie-srv-ex01.d2000.local"
 +
 +sudo systemctl restart postfix
 +sudo systemctl restart saslauthd
 </code> </code>
postfix_test.1760775982.txt.gz · Zuletzt geändert: 2025/10/18 10:26 von jango