RHEL-5/CentOS-5的cyrus-sasl默认没有打开authdaemon的支持,为了使用集中认证的authlib,必须打开这个支持。为此我们必须删除系统的cyrus-sasl软件包,替换成打开了authdaemon支持的sasl软件包。
删除系统的cyrus-sasl:
shell
# rpm -e cyrus-sasl --nodeps
安装新的支持authdaemon的软件包
shell
# yum install cyrus-sasl
Postfix的SMTP认证需要透过Cyrus-SASL,连接到authdaemon获取认证信息。
编辑main.cf
shell
增加如下内容:
# smtpd related config
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_non_fqdn_hostname,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_unauth_destination,
reject_unauth_pipelining,
reject_invalid_hostname,
# SMTP sender login matching config
smtpd_sender_restrictions =
permit_mynetworks,
reject_sender_login_mismatch,
reject_authenticated_sender_login_mismatch,
reject_unauthenticated_sender_login_mismatch
smtpd_sender_login_maps =
mysql:/etc/postfix/mysql_virtual_sender_maps.cf,
mysql:/etc/postfix/mysql_virtual_alias_maps.cf
# SMTP AUTH config here
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
shell
确保其内容为:
pwcheck_method: authdaemond log_level: 3 mech_list: PLAIN LOGIN authdaemond_path:/var/spool/authdaemon/socket
重新启动postfix:
shell
通过以下命令获得postmaster@extmail.org的用户名及密码的BASE64编码:
shell
内容如下:
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==
shell
内容如下:
ZXh0bWFpbA==
然后本机测试:
shell
其过程如下:
Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'. 220 mail.extmail.org ESMTP Postfix - by extmail.org ehlo demo.domain.tld << 输入内容 250-mail.extmail.org 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-AUTH LOGIN PLAIN 250-AUTH=LOGIN PLAIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN auth login << 输入内容 334 VXNlcm5hbWU6 cG9zdG1hc3RlckBleHRtYWlsLm9yZw== << 输入内容 334 UGFzc3dvcmQ6 ZXh0bWFpbA== << 输入内容 235 2.0.0 Authentication successful quit << 输入内容 221 2.0.0 Bye
最后出现235 Authentication Successful 表明认证成功了。