Postfix can relay the SASL framework to provide SMTP password authentication.
SMTP password authentication is suitable for roaming users who are outside of trusted network. They are still allowed to send email without relaxing SMTP restrictions , which could introduce spam emails.
Postfix version 2.3 onwards supports two SASL implementations(This post will discuss cryus)
[Centos 5.5 ] $ postconf -a cyrus dovecotSASL Mechanisms
- SASL mechanisms: DIGEST-MD5 CRAM-MD5 use encrypted password , but they are only supported in saslauthd mechanism:sasldb,sql,ldapdb
cyrus-sasl-md5 package provides library for DIGEST-MD5 CRAM-MD5
- SASL mechanisms: PLAIN LOGIN use clear text password, it is supported saslauthd mechanism: pam, but the clear text can be protected by TLS
cyrus-sasl-plain package provides library for PLAIN LOGIN
NOTE:
- This post only discuss SASL PLAIN LOGIN in saslauthd PAM
- make sure you already have a basic working Postfix before continue next steps
1. Install and configure saslauthd
2. Enable SASL in postfix$rpm -qa | grep sascyrus-sasl-2.1.22-5.el5_4.3cyrus-sasl-plain-2.1.22-5.el5_4.3cyrus-sasl-lib-2.1.22-5.el5_4.3#saslauthd should be configured to use pam mechanism
$ grep MECH /etc/sysconfig/saslauthdMECH=pam#start /etc/init.dd/saslauthd and test it
#smtp is service name /etc/pam.d/smtp
$testsaslauthd -u guest01 -p Pass001 -s smtp
0: OK "Success."
3.Restart postfix and test the authentication$cat /etc/postfix/main.cfsmtpd_sasl_auth_enable = yesbroken_sasl_auth_clients = yessmtp_sasl_security_options = noanonymoussmtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
4. Enable TLS (Optional) to protect clear text password in PLAIN LOGIN#First test: telnet to check if PLAIN LOGIN is shown
$(echo "ehlo localhost"; sleep 2; echo "quit") | telnet localhost 25250-AUTH PLAIN LOGIN DIGEST-MD5 CRAM-MD5## you can limit mechanism type
$cat /usr/lib64/sasl2/smtpd.confpwcheck_method: saslauthdmech_list: plain login#Second test: test username and password by converting them to base64
$ printf "\0guest01\0Pass001" |openssl base64AGd1ZXN0MDEAUGFzczAwMQ==$ (echo "AUTH PLAIN AGd1ZXN0MDEAUGFzczAwMQ=="; sleep 2 )| telnet localhost 25Trying 127.0.0.1...Connected to localhost (127.0.0.1).Escape character is '^]'.220 mail.example.com ESMTP Postfix235 2.0.0 Authentication successfulConnection closed by foreign host.
$cat /etc/postfix/main.cfsmtpd_use_tls = yessmtpd_tls_CAfile = /etc/postfix/certs/ca.pemsmtpd_tls_cert_file = /etc/postfix/certs/postfix.pemsmtpd_tls_key_file = /etc/postfix/certs/postfix.keysmtpd_tls_loglevel = 1
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.