[root@tsai
/root]# cd /usr/share/sendmail-cf/cf
[root@tsai cf]# vi redhat.mc .......... dnl TRUST_AUTH_MECH(`DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl dnl define(`confAUTH_MECHANISMS', `DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl .......... DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA') .......... |
..........
TRUST_AUTH_MECH(`DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl define(`confAUTH_MECHANISMS', `DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl .......... DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA') .......... |
[root@tsai
/root]# cd /usr/share/sendmail-cf/cf
[root@tsai cf]# sh Build redhat.cf [root@tsai cf]# mv /etc/sendmail.cf /etc/sendmail.cf.old <==备份旧的档案 [root@tsai cf]# cp redhat.cf /etc/sendmail.cf <==加入新的参数档 [root@tsai cf]# /etc/rc.d/init.d/sendmail restart <==重新启动 sendmail |
既然 Red Hat 7.1 可以具有身份认证的功能,那么其它版本的 Red Hat 是否可以呢?当然可以了!只是动作会变的比较麻烦就是了!因为 Cyrus-sasl 这个套件所支持的 Sendmail 版本需要大于 8.10.0 以上,而且 Red Hat 6.X 版并无预设的 Cyrus-sasl 套件,所以你必须要捉下这两个套件来安装才行!
- 下载所需套件:
sendmail:sendmail 可以到 sendmail 的网站上下载最新的套件,或者由『这里』下载;
cyrus-sasl:这个认证函式库可以到 Carnegie Mellon University 网站上看看,或者由『这里』下载;
- 移除与备份之前版本的 sendmail 设定:
为了让你未来还可以使用旧的 sendmail 来安装你的原先的设定,所以请备份以下的档案吧(使用 tar 是一个不错的主意!):再来则是移除一些旧的套件:
- /etc/sendmail.cf (或 /etc/mail/sendmail.cf)
- /etc/mail/*
- /usr/sbin/sendmail
- rpm -e mutt
- rpm -e fetchmail
- rpm -e fetchmailconf
- rpm -e --nodeps sendmail
- 安装 Cyrus-sasl 函式库:
假设你的 cyrus-sasl-1.5.27.tar.gz 放置在 root 底下,我预设的解压缩目录是在 /usr/local/src 底下,那我的步骤就是:
基本上大概这样就安装完成 cyrus-sasl 这个套件了!
[root@tsai /root]# cd /usr/local/src
[root@tsai src]# tar -zxvf /root/cyrus-sasl-1.5.27.tar.gz
..........(略)[root@tsai src]# cd cyrus-sasl-1.5.27
[root@tsai cyrus-sasl-1.5.27]# ./configure --prefix=/usr/local \
> --enable-plain --enable-login --enable-pwcheck
上面这一行,在于使你的 cyrus-sasl 安装在 /usr/local 目录中;
并且已经启动了 password_check 的模式。
..........(略)[root@tsai cyrus-sasl-1.5.27]# make clean; make ; make install
..........(略)[root@tsai cyrus-sasl-1.5.27]# cd /usr/lib
[root@tsai lib]# ln -s /usr/local/lib/sasl .
[root@tsai lib]# ln -s /usr/local/lib/libsasl* .
上面这几行在将你的数据 Link 到 Red Hat 的预设路径中。[root@tsai sbin]# cd /usr/lib/sasl
[root@tsai sasl]# echo 'pwcheck_method: shadow' > Sendmail.conf
这个目的在于产生一个 Red Hat 的密码认证数据库。
- 安装 sendmail 最新版(到 2001/12 为止):
假设我们的 sendmail.8.12.1.tar.gz 同样是放置在 /root 底下,而解压缩档案要放在 /usr/local/src 底下:
基本上这样就设定完成了!不过要注意的是,还需要做一下测试!因为在我的系统中,虽然可以具有身份认证的功能,但是一开始却是捉不到 /etc/sasldb 这个档案!真是很奇怪!后来,我在 /usr/local/sbin 底下,执行了 ./saslpasswd 及 ./sasldblistusers 这样就可以了!或者是我的系统太旧了吧!
[root@tsai /root]# cd /usr/local/src
[root@tsai src]# tar -zxvf /root/sendmail.8.12.1.tar.gz
.........(略)[root@tsai src]# cd sendmail-8.12.1
[root@tsai sendmail-8.12.1]# cd /usr/local/src/sendmail-8.12.1/devtools/Site
[root@tsai Site]# vi site.config.m4 <==这个档案内容如下:PREPENDDEF(`confMAPDEF', `-DMAP_REGEX')
PREPENDDEF(`confOPTIMIZE', `-O2')
APPENDDEF(`confENVDEF', `-DTCPWRAPPERS -DSASL')
APPENDDEF(`conf_sendmail_LIBS', `-lwrap -lsasl')
APPENDDEF(`confLIBDIRS', `-L/usr/local/lib')
APPENDDEF(`confINCDIRS', `-I/usr/local/include')[root@tsai bin]# cd /usr/local/src/sendmail-8.12.1/sendmail
[root@tsai sendmail]# sh Build -c -f /usr/local/src/sendamil-8.12.1/devtools/Site/site.config.m4
.........(开始编译,略)底下为 sendmail 8.12 的新功能,需要增加一个 smmsp 及 smmsp
使用者,这样才可以确保安全性!
[root@tsai sendmail]# groupadd -g 25 smmsp
[root@tsai sendmail]# useradd -g smmsp -u 25 -d /var/spool/clientmqueue -s /dev/null smmsp
[root@tsai mail]# chown -R smmsp:smmsp /var/spool/clientmqueue
[root@tsai mail]# chmod -R 770 /var/spool/clientmqueue
新增一个使用者,他无法登入,ID 是 25 号!
这个使用者的家目录是 /var/spool/clientmqueue
主要仅用于邮件的收受与传递!增加这个使用者是
sendmail 8.12 板后新增的功能!主要的目的在于
提供更安全的 sendmail 使用环境![root@tsai sendmail]# cd /usr/local/src/sendmail-8.12.1/cf/cf
[root@tsai cf]# cp generic-linux.mc sendmail.mc
[root@tsai cf]# cat ../feature/access_db.m4 >> sendmail.mc
[root@tsai cf]# cat ../feature/delay_checks.m4 >> sendmail.mc
[root@tsai cf]# cat ../feature/virtusertable.m4 >> sendmail.mc
[root@tsai cf]# vi sendmail.mc <==在最后面加上两行
TRUST_AUTH_MECH(`LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `LOGIN PLAIN')dnl[root@tsai cf]# sh Build sendmail.cf
[root@tsai cf]# sh Build install-cf
[root@tsai cf]# cd /usr/local/src/sendmail-8.12.1/sendmail
[root@tsai sendmail]# sh Build install
[root@tsai sendmail]# cd ../makemap
[root@tsai makemap]# sh Build install
[root@tsai makemap]# cd ../mailstats
[root@tsai mailstats]# sh Build install
[root@tsai mailstats]# cd /usr/local/src/sendmail-8.12.1
[root@tsai sendmail-8.12.1]# sh Build install[root@tsai mail]# vi access <==这个档案内容如下:
# makemap hash /etc/mail/access_db < /etc/mail/access
localhost.localdomain RELAY
localhost RELAY
127.0.0.1 RELAY[root@tsai mail]# vi local-host-names
tsai.adsldns.org[root@tsai mail]# vi aliases <==aliases的内容!
mailer-daemon: postmaster
postmaster: root
bin: root
daemon: root
adm: root
lp: root
sync: root
shutdown: root
halt: root
news: root
uucp: root
news: root
uucp: root
operator: root
games: root
gopher: root
ftp: root
nobody: root
apache: root
named: root
xfs: root
gdm: root
mailnull: root
postgres: root
squid: root
rpcuser: root
rpc: root
ingres: root
system: root
toor: root
manager: root
dumper: root
abuse: root
newsadm: news
newsadmin: news
usenet: news
ftpadm: ftp
ftpadmin: ftp
ftp-adm: ftp
ftp-admin: ftp
decode: root
root: vbird
上面的设定是随系统而变的喔!
不过,最后一行是将 root 的信都寄一份给 vbird 的意思![root@tsai mail]# touch virtusertable
[root@tsai mail]# makemap hash access.db < access
[root@tsai mail]# makemap hash virtusertable.db < virtusertable
[root@tsai mail]# newaliases[root@tsai mail]# /usr/sbin/sendmail -bd -q30m
启动 sendmail 啰!开始进行测试一下!
[root@tsai mail]# telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 tsai.adsldns.org ESMTP Sendmail 8.12.1/8.12.1; Thu, 13 Dec 2001 14:02:30 +0800
ehlo localhost <==这里输入测试点!
250-tsai.adsldns.org Hello localhost [127.0.0.1] (may be forged), pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH LOGIN PLAIN <==有这一行就是成功啦!
250-DELIVERBY
250 HELP
- 设定开机时加载:
剩下一个重要的步骤了!就是在开机的时候载入 Sendmail 啦!直接修改 /etc/rc.d/rc.local 在最后一行加入:/usr/sbin/sendmail -bd -q30m
就可以啦!OK!
- 设定客户端:
就跟上面的设定相同,去试试看吧: