Deutsch| English

Der perfekte Server - Debian Etch (4.0)

11 Postfix mit SMTP-AUTH und TLS

Um Postfix mit SMTP-AUTH und TLS zu installieren, sind folgende Schritte nötig:

apt-get install postfix libsasl2 sasl2-bin libsasl2-modules libdb3-util procmail

Zwei Fragen erscheinen, die man so beantwortet:

General type of configuration? <-- Internet Site
Mail name? <-- server1.example.com

Dann das ausführen:

dpkg-reconfigure postfix

Jetzt erscheinen weitere Fragen:

General type of configuration? <-- Internet Site
Where should mail for root go <-- [blank]
Mail name? <-- server1.example.com
Other destinations to accept mail for? (blank for none) <-- server1.example.com, localhost.example.com, localhost.localdomain, localhost
Force synchronous updates on mail queue? <-- No
Local networks? <-- 127.0.0.0/8
Use procmail for local delivery? <-- Yes
Mailbox size limit <-- 0
Local address extension character? <-- +
Internet protocols to use? <-- all

Als nächstes dieses eingeben:

postconf -e ’smtpd_sasl_local_domain =’
postconf -e ’smtpd_sasl_auth_enable = yes’
postconf -e ’smtpd_sasl_security_options = noanonymous’
postconf -e ‘broken_sasl_auth_clients = yes’
postconf -e ’smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination’
postconf -e ‘inet_interfaces = all’
echo ‘pwcheck_method: saslauthd’ >> /etc/postfix/sasl/smtpd.conf
echo ‘mech_list: plain login’ >> /etc/postfix/sasl/smtpd.conf

Danach erstellt man die Zertifizierung für TLS:

mkdir /etc/postfix/ssl
cd /etc/postfix/ssl/
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024

chmod 600 smtpd.key
openssl req -new -key smtpd.key -out smtpd.csr

openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt

openssl rsa -in smtpd.key -out smtpd.key.unencrypted

mv -f smtpd.key.unencrypted smtpd.key
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650

Nun konfiguriert man Postfix für TLS:

postconf -e ’smtpd_tls_auth_only = no’
postconf -e ’smtp_use_tls = yes’
postconf -e ’smtpd_use_tls = yes’
postconf -e ’smtp_tls_note_starttls_offer = yes’
postconf -e ’smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key’
postconf -e ’smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt’
postconf -e ’smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem’
postconf -e ’smtpd_tls_loglevel = 1′
postconf -e ’smtpd_tls_received_header = yes’
postconf -e ’smtpd_tls_session_cache_timeout = 3600s’
postconf -e ‘tls_random_source = dev:/dev/urandom’
postconf -e ‘myhostname = server1.example.com’

Die Datei /etc/postfix/main.cf sollte so aussehen:

cat /etc/postfix/main.cf

# See /usr/share/postfix/main.cf.dist for a commented, more complete version

# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

# TLS parameters
smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
smtpd_use_tls = yes
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = server1.example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = server1.example.com, localhost.example.com, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
smtpd_sasl_local_domain =
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_tls_auth_only = no
smtp_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom

Jetzt Postfix neu starten:

/etc/init.d/postfix restart

Die Authentisierung wird mit saslauthd ausgeführt. Da Postfix in /var/spool/postfix chrooted läuft und das Programm richtig arbeiten soll, müssen einige Angaben geändert werden:

mkdir -p /var/spool/postfix/var/run/saslauthd

Jetzt /etc/default/saslauthd editieren, um saslauthd zu aktivieren. Nun START to yes eingeben und die Zeile OPTIONS=”-c” in OPTIONS=”-c -m /var/spool/postfix/var/run/saslauthd -r” ändern:

vi /etc/default/saslauthd

#
# Settings for saslauthd daemon
#

# Should saslauthd run automatically on startup? (default: no)
START=yes

# Which authentication mechanisms should saslauthd use? (default: pam)
#
# Available options in this Debian package:
# getpwent  -- use the getpwent() library function
# kerberos5 -- use Kerberos 5
# pam       -- use PAM
# rimap     -- use a remote IMAP server
# shadow    -- use the local shadow password file
# sasldb    -- use the local sasldb database file
# ldap      -- use LDAP (configuration is in /etc/saslauthd.conf)
#
# Only one option may be used at a time. See the saslauthd man page
# for more information.
#
# Example: MECHANISMS="pam"
MECHANISMS="pam"

# Additional options for this mechanism. (default: none)
# See the saslauthd man page for information about mech-specific options.
MECH_OPTIONS=""

# How many saslauthd processes should we run? (default: 5)
# A value of 0 will fork a new process for each connection.
THREADS=5

# Other options (default: -c)
# See the saslauthd man page for information about these options.
#
# Example for postfix users: "-c -m /var/spool/postfix/var/run/saslauthd"
# Note: See /usr/share/doc/sasl2-bin/README.Debian
OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r"

Jetzt saslauthd starten:

/etc/init.d/saslauthd start

Um zu überprüfen, ob SMTP-AUTH und TLS richtig funktionieren, gibt man folgende Befehle ein:

telnet localhost 25

Wenn man die Verbindung zum Postfix-Mailserver hergestellt hat, folgenden Befehl eingeben:

ehlo localhost

Wenn man jetzt die Zeilen

250-STARTTLS

und

250-AUTH PLAIN LOGIN

sieht hat alles geklappt!

Die Anzeige auf meinem System sah so aus:

server1:/etc/postfix/ssl# telnet localhost 25
Trying 127.0.0.1…
Connected to localhost.localdomain.
Escape character is ‘^]’.
220 server1.example.com ESMTP Postfix (Debian/GNU)
ehlo localhost
250-server1.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.

Jetzt

quit

eingeben, um zur Eingabeaufforderung zurückzukehren.

12 Courier-IMAP/Courier-POP3

Für die Installation von Courier-IMAP/Courier-IMAP-SSL (für IMAPs auf dem Port 993) und Courier-POP3/Courier-POP3-SSL (für POP3s auf dem Port 995) sind folgende Eingaben nötig:

apt-get install courier-authdaemon courier-base courier-imap courier-imap-ssl courier-pop courier-pop-ssl courier-ssl gamin libgamin0 libglib2.0-0

Nun erscheinen zwei Fragen:

Create directories for web-based administration ? <-- No
SSL certificate required <-- Ok

Wenn man ISPConfig nicht benutzen möchte, konfiguriert man Postfix, um die Emails an ein Email-Verzeichnis des Benutzers umzuleiten*:

postconf -e ‘home_mailbox = Maildir/’
postconf -e ‘mailbox_command =’
/etc/init.d/postfix restart

*Achtung: Dies muss man nicht machen, wenn man ISPConfig auf seinem System nutzen möchte - ISPConfig führt die nötige Konfiguration selbst aus, in dem es Procmail-Rezepte nutzt. Man sollte vorher sichergehen, dass Maildir aktiviert ist und zwar unter Management -> Server -> Settings -> EMail im ISPConfig-Web-Interface.

 

 

8 Responses to “Der perfekte Server - Debian Etch (4.0)”

  1. ChrisCross Sagt:

    Syntax musste teilweise korrigiert werden, ISPConfig läuft, SMTP Auth leider nicht.

    Hatte das ganze vorher ohne TLS installiert, da lief der SMTP auth!

  2. paepke Sagt:

    Blöde frage:
    Wie bekomme ich das Sternchen raus um nur “Standard system” zu installieren, Leider ist bei mir Desktop immer aktiviert und ich bekomme das Sternchen nicht raus… Was muss man da drücken? * geht nicht und x auch nicht??????/?//

  3. tenorchris Sagt:

    Einfach mit den Pfeiltasten auf das Feld navigieren und dann die Leertaste drücken. Und schon verschwindet das Sternchen

  4. Blackwolf Sagt:

    Es wäre schön, wenn man den Hinweis:

    “Du bekommst eine Fehlermeldung wie diese, wenn Du den Befehl quotacheck -avugm zum ersten Mal laufen lässt.

    quotacheck: WARNING - Quotafile //quota.user was probably truncated. Cannot save quota settings…
    quotacheck: WARNING - Quotafile //quota.group was probably truncated. Cannot save quota settings…

    Das ist ganz normal und nichts, worüber man sich sorgen müsste!”

    … wie hier ---> http://www.howtoforge.de/howto/samba-domaincontroller-server-fur-kleine-arbeitsgruppen-mit-ubuntu-710/

    … auch noch in das Howto mit aufnehmen könnte,… es hatte mir dann doch - erstmal - einige Schweißtropfen auf die Stirn gezaubert … *smile

  5. E-mails senden, Relayhost, Postfix, smtp gmail - Seite 2 - Linux: Linux-Forum Sagt:

    [...] Ich wusste dass etwas mit dem sasl nicht stimmen musste. Ich habe 2 Tuts genutzt. Eines davon war http://www.howtoforge.de/howto/das-p…ian-etch-40/5/ dabei habe ich aber den Schritt weggelassen, der Sasl konfiguriert! Und es ging. Richtig plausibel [...]

  6. vzcrsa Sagt:

    hier sollte auch noch hinzugefügt werden wie Java integriert wird, da mitlerweile viele seiten mit Java laufen.

  7. wuiso Sagt:

    Bei mir läuft saslauthd nich. was soll ich nun machen?

  8. oz42 Sagt:

    Schade - postfix will immer noch /etc/sasldb2 einsehen:
    Jan 7 10:20:25 foo postfix/smtpd[12532]: warning: SASL authentication problem: unable to open Berkeley db /etc/sasldb2: No such file or directory
    Jan 7 10:20:25 foo postfix/smtpd[12532]: warning: SASL authentication failure: Password verification failed
    Der beschriebene Weg mit saslauthd funktioniert offenbar nicht.

Kommentar

Du musst eingeloggt um einen Kommentar zu hinterlassen.