Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
applications:postfix [Le 13/01/2007, 23:14] charlax |
— (Version actuelle) | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | Traduit Par [[utilisateurs:phetu|phetu]] de wiki.ubuntu.com/postfix | ||
- | Quelques ajouts depuis (à prendre en compte en cas de re-traduction). | ||
- | |||
- | === Introduction === | ||
- | |||
- | Postfix c'est l'agent de transfère de courriel (MTA) par défaut d'Ubuntu. Il est dans le répertoire "main" ce qui veux dire qu'il reçoit les mises à jour de sécurité. Cette page explique comment on l'installe et comment on le configure pour qu'il soit un serveur SMTP qui utilise une connexion sécurisée. | ||
- | |||
- | === Installation === | ||
- | |||
- | Pour installer Postfix avec SMTP-AUTH et TLS vous devez faire: //A noter que postfix-tls n'existe plus, il suffit de suivre la procédure sans s'en soucier | ||
- | |||
- | apt-get install postfix postfix-tls libsasl2 sasl2-bin libsasl2-modules libdb3-util procmail | ||
- | |||
- | |||
- | === Configuration === | ||
- | |||
- | Pour la configuration tappez: | ||
- | dpkg-reconfigure postfix | ||
- | |||
- | |||
- | Et insérez les détails suivant quand on vous les demande (replacer server1.example.com par votre nom de domaine): | ||
- | Internet Site | ||
- | NONE | ||
- | server1.example.com | ||
- | server1.example.com, localhost.example.com, localhost | ||
- | No | ||
- | 127.0.0.0/8 | ||
- | 0 | ||
- | + | ||
- | |||
- | Ensuite faire les commandes suivantes: | ||
- | |||
- | 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 | ||
- | | ||
- | 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 | ||
- | | ||
- | 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' | ||
- | | ||
- | |||
- | Le fichier /etc/postfix/main.cf doit ressemblé à ceci: | ||
- | |||
- | # See /usr/share/postfix/main.cf.dist for a commented, more complete version | ||
- | |||
- | smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) | ||
- | 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 | ||
- | | ||
- | 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 | ||
- | relayhost = | ||
- | mynetworks = 127.0.0.0/8 | ||
- | mailbox_size_limit = 0 | ||
- | recipient_delimiter = + | ||
- | inet_interfaces = 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 | ||
- | smtpd_use_tls = yes | ||
- | smtp_tls_note_starttls_offer = yes | ||
- | smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key | ||
- | smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt | ||
- | 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 | ||
- | |||
- | |||
- | Redémarrez le démon avec cette commande: | ||
- | |||
- | /etc/init.d/postfix restart | ||
- | |||
- | === Authentification === | ||
- | |||
- | L'authentification utilise **saslauthd**. | ||
- | |||
- | Il est possible de changer quelques détails pour le faire fonctionner proprement. Postfix exécutant "chroot" dans /var/spool/postfix nous devons faire: | ||
- | |||
- | |||
- | mkdir -p /var/spool/postfix/var/run/saslauthd | ||
- | rm -fr /var/run/saslauthd | ||
- | |||
- | Maintenant éditez /etc/default/saslauthd pour y activer saslauthd. Enlevez pour ce faire le # devant START=yes et ajouter la ligne : | ||
- | PARAMS="-m /var/spool/postfix/var/run/saslauthd": | ||
- | |||
- | # This needs to be uncommented before saslauthd will be run automatically | ||
- | START=yes | ||
- | | ||
- | PARAMS="-m /var/spool/postfix/var/run/saslauthd" | ||
- | | ||
- | # You must specify the authentication mechanisms you wish to use. | ||
- | # This defaults to "pam" for PAM support, but may also include | ||
- | # "shadow" or "sasldb", like this: | ||
- | # MECHANISMS="pam shadow" | ||
- | | ||
- | MECHANISMS="pam" | ||
- | |||
- | '''Note''': Si vous préférez, vous pouvez utiliser "shadow" au lieu de "pam". Ceci utilisera MD5 au lieu de password et le rendra parfaitement sécurisé. Le nom d'utilisateur et le mot de passe requis pour l'authentification sera le même que pour les utilisateurs de votre système. | ||
- | |||
- | Finallement vous devez éditer /etc/init.d/saslauthd et changer les lignes (ligne 48 à peu près dans le fichier) : | ||
- | |||
- | |||
- | dir=`dpkg-statoverride --list $PWDIR` | ||
- | |||
- | en | ||
- | |||
- | #dir=`dpkg-statoverride --list $PWDIR` | ||
- | |||
- | |||
- | Ensuite changez la variable PWDIR et PIDFILE et ajoutez la variable dir au début du fichier: | ||
- | |||
- | |||
- | PWDIR="/var/spool/postfix/var/run/${NAME}" | ||
- | PIDFILE="${PWDIR}/saslauthd.pid" | ||
- | dir="root sasl 755 ${PWDIR}" | ||
- | |||
- | === Les tests === | ||
- | Maintenant démarrez saslauthd: | ||
- | |||
- | /etc/init.d/saslauthd start | ||
- | |||
- | pour voir si SMTP-AUTH et TLS fonctionne correctement tapez cette commande : | ||
- | |||
- | telnet localhost 25 | ||
- | |||
- | Ensuite après avoir établi la connexion avec postfix tapez : | ||
- | |||
- | EHLO somename.tld | ||
- | |||
- | Si vous voyez ces lignes | ||
- | |||
- | 250-STARTTLS | ||
- | 250-AUTH | ||
- | |||
- | Ça fonctionne!!! | ||
- | |||
- | Tapez | ||
- | quit | ||
- | |||
- | Pour retourner dans l'invite de commande. | ||
- | |||
- | ===Pour aller plus loin=== | ||
- | |||
- | Vous pouvez avoir envie d'installer un serveur Imap. La configuration est un peu ardue avec procmail. Vous pouvez utiliser maildrop à la place. | ||
- | apt-get install maildrop | ||
- | |||
- | Il faudra modifier la ligne suivante dans main.cf : | ||
- | mailbox_command = procmail -a "$EXTENSION" | ||
- | |||
- | en : | ||
- | mailbox_command = maildrop | ||
- | |||
- | N'oubliez pas de créer pour chaque utilisateur un dossier Maildir : | ||
- | |||
- | maildirmake.courrier ~/Maildir | ||
- | |||
- | Et d'activer l'option dans /etc/maildroprc (en enlevant le #) | ||