Saturday, August 9, 2008

SMTP Auth

The perfect steps to configure SMTP auth in sendmail as well for Postfix! The instrctions are specifically for RHEL-4 systems, and should have installed sendmail/postfix, and saslauthd packages.

Sendmail
Enter or uncomment following in /etc/mail/sendmail.mc file.
TRUST_AUTH_MECH(`DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl

define(`confCACERT_PATH',`/
etc/pki/tls/certs')
define(`confCACERT',`/etc/pki/
tls/certs/ca- bundle.crt')
define(`confSERVER_CERT',`/
etc/pki/tls/esquarecerts/servercert.pem')
define(`confSERVER_KEY',`/etc/
pki/tls/esquarecerts/serverkey.pem')

FEATURE(authinfo)dnl

Save the file. And run following commands to generate the certificates.
cd /etc/pki/tls/certs/
make sendmail.pem
Provide necessary information, and that completes the cert generation.
If you want the authentication using pam modify following line in /etc/sysconfig/saslauthd and in /etc/init.d/saslauthd
MECH=shadow
Change it to....
MECH=pam
Save the files and run:

cd /etc/mail
make
/etc/init.d/sendmail restart
That should be OK to start sendmail with SMTP Auth. Following are Postfix instructions.

Postfix

Following RPMs must be installed in order to configure SMTP auth with Postfix. You can check with rpm command:

rpm -qa |grep cyrus

cyrus-sasl
cyrus-sasl-devel
cyrus-sasl-md5
cyrus-sasl-plain


Add/modify following lines in /etc/postfix/main.cf to look like following:

mynetworks = 127.0.0.0/8

smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname

smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, check_relay_domains


And following lines in master.cf:
smtp inet n - n - - smtpd
to..
smtp inet n - n - - smtpd -v
reload postfix service
/etc/init.d/postfix reload
Thats done! You should be able to use SMTP auth with your clients now.

------------------------------------------------------------------------------------------------------------------

No comments: