RHEL4/CentOS4的cyrus-sasl默认没有打开authdaemon的支持,为了使用集中认证的authlib,必须打开这个支持。为此我们必须删除系统的cyrus-sasl软件包,替换成打开了authdaemon支持的sasl软件包。

1、安装cyrus-sasl

删除系统的cyrus-sasl:

 

shell

# rpm -e cyrus-sasl --nodeps

安装新的支持authdaemon的软件包

 

shell

# yum install cyrus-sasl2、配置main.cf文件

Postfix的SMTP认证需要透过Cyrus-SASL,连接到authdaemon获取认证信息。

编辑main.cf

 

shell

# vi /etc/postfix/main.cf

增加如下内容:

# smtpd related configsmtpd_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 configsmtpd_sender_restrictions = permit_mynetworks, reject_sender_login_mismatch, reject_authenticated_sender_login_mismatch, reject_unauthenticated_sender_login_mismatchsmtpd_sender_login_maps = mysql:/etc/postfix/mysql_virtual_sender_maps.cf, mysql:/etc/postfix/mysql_virtual_alias_maps.cf # SMTP AUTH config herebroken_sasl_auth_clients = yessmtpd_sasl_auth_enable = yessmtpd_sasl_local_domain = $myhostnamesmtpd_sasl_security_options = noanonymous3、编辑smtpd.conf文件

shell

# vi /usr/lib/sasl2/smtpd.conf

确保其内容为:

pwcheck_method: authdaemondlog_level: 3mech_list: PLAIN LOGINauthdaemond_path:/var/spool/authdaemon/socket

重新启动postfix:

 

shell

# service postfix start 4、测试SMTP认证

通过以下命令获得postmaster@extmail.org的用户名及密码的BASE64编码:

 

shell

# perl -e ‘use MIME::Base64; print encode_base64(”postmaster\@extmail.org”)’

内容如下:

cG9zdG1hc3RlckBleHRtYWlsLm9yZw==

shell

# perl -e ‘use MIME::Base64; print encode_base64(”extmail”)’

内容如下:

ZXh0bWFpbA==

然后本机测试:

 

shell

# telnet localhost 25

其过程如下:

Trying 127.0.0.1...Connected to localhost.localdomain (127.0.0.1).Escape character is '^]'.220 mail.extmail.org ESMTP Postfix - by extmail.orgehlo demo.domain.tld << 输入内容250-mail.extmail.org250-PIPELINING250-SIZE 10240000250-VRFY250-ETRN250-AUTH LOGIN PLAIN250-AUTH=LOGIN PLAIN250-ENHANCEDSTATUSCODES250-8BITMIME250 DSNauth login << 输入内容334 VXNlcm5hbWU6cG9zdG1hc3RlckBleHRtYWlsLm9yZw== << 输入内容334 UGFzc3dvcmQ6ZXh0bWFpbA== << 输入内容235 2.0.0 Authentication successfulquit << 输入内容221 2.0.0 Bye

最后出现235 Authentication Successful 表明认证成功了。