加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Cyrus-SASL 安装

发布时间:2020-12-16 00:20:50 所属栏目:大数据 来源:网络整理
导读:一 安装 cyrus-sasl 将系统自带的sasl先备份 1.mv /usr/lib/sasl /usr/lib/sasl.OFF 2.mv /usr/lib/sasl2 /usr/lib/sasl2.OFF 取源码安装 1. wget http://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.21.tar.gz 2. tar zxvf cyrus-sasl-2.1.21.tar.gz

一 安装 cyrus-sasl
将系统自带的sasl先备份
1.mv /usr/lib/sasl /usr/lib/sasl.OFF
2.mv /usr/lib/sasl2 /usr/lib/sasl2.OFF

取源码安装
1. wget http://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.21.tar.gz
2. tar zxvf cyrus-sasl-2.1.21.tar.gz
3. cd cyrus-sasl-2.1.21
4. ./configure /
--disable-anon -enable-plain --enable-login /
--enable-sql --with-mysql=/usr/local/mysql /
--with-mysql-includes=/usr/local/mysql/include/mysql /
--with-mysql-libs=/usr/local/mysql/lib/mysql /
--with-authdaemond
5. make
6. make install

更新lib库
1. echo "/usr/local/lib" >> /etc/ld.so.conf
2. ldconfig

建立符号连接
1. ln -s /usr/local/lib/sasl2 /usr/lib/sasl2

二 配置 Cyrus-SASL?
1. vi /usr/local/lib/sasl2/smtpd.conf?
? (加入一行:pwcheck_method: auxprop)
? 这种方式建立独立的用户跟密码对应的加密文件,用于验证客户端是否有使用此smtp的权限
其中 auxprop (Auxiliary Property Plug-ins 辅助性的专署外挂模块),起外挂模块使用Cyrus Sasl的 sasldb程序。这种方法不需要
saslauthd daemon.但是必须把所有的client 的帐户,密码放到一个专用的外部密码文件中。

2. 加入一个测试的帐户? ayla/pass (其中的 mail.test.com 与 PostFix 的主配文件main.cf中的myhostname要保持一致)
?? /usr/sbin/saslpasswd2 -c -u mail.test.com ayla
?? (两次输入密码: 123456)
3. 这个存放client的文件,默认的位置在 /etc/sasldb2


三 重装 PostFix
(先停掉使用的postfix : postfix stop)
1.make tidy
2.% make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL /
?? -I/usr/local/include/sasl" AUXLIBS="-L/usr/local/lib -lsasl2"
3.make? && make install

四 配置Postfix,让客户端使用验证通过才能发邮件
1. vi /etc/postfix/main.cf
在最后加上:
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_sasl_authenticated permit_auth_destination reject
broken_sasl_auth_clients = yes
smtpd_sasl_security_options = noanonymous
?
五 测试
1.telnet mail.test.com 25
>
250-mail.test.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH DIGEST-MD5 LOGIN GSSAPI PLAIN CRAM-MD5 OTP
250-AUTH=DIGEST-MD5 LOGIN GSSAPI PLAIN CRAM-MD5 OTP
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN?
?
2.程序测试
使用Net::SMTP_AUTH 这个模块,下载解压,其中的README文件里说:
This module requires:
?? - Net::SMTP (should be obvious)
?? - MIME::Base64
?? - Digest::HMAC_MD5
?? - Authen::SASL
?? - Authen::NTLM (optional for NTLM)

所以就就把没有装的模块先装上。($perl -MCPAN -e 'install Net::SMTP_auth' 安装更简单,但是成功与否取决于网络,
有时国内的CPAN镜像速度奇慢无比)
3. 安装
? perl Makefile.PL
? make test
? make install

4.测试脚本 test.pl
#!/usr/bin/perl?
use Net::SMTP_auth;
$smtp = Net::SMTP_auth->new('mail.test.com');
$smtp->auth('CRAM-MD5','test','13456');?? ### ===>> 这里就是第二步配置的用户名跟密码
$smtp->mail('ayla@test.com');
$smtp->to('ayla@test.com');
$smtp->data();
$smtp->datasend("To: postmaster/n");
$smtp->datasend("/n");
$smtp->datasend("A test message/n");
$smtp->dataend();
$smtp->quit;??

5. 检验发送结果。收信客户端 跟 /var/log/maillog

http://blog.csdn.net/Aylazhang/article/details/1678790

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读