Postfix SMTP Authentication - On The Secure Port Only
Postfix SMTP Authentication - On The Secure Port OnlySo let's say your users are going away for holidays but need to use your mailserver to relay mail from outside the organisation... Let's set up SMTP authentication for the secure port only and allow access to this from outside your network. [yourserver = server hostname] cd /etc/postfix Paste under mynetworks: ####### smtp auth smtpd_tls_auth_only = no smtp_use_tls = yes smtpd_sasl_auth_enable = yes smtpd_sasl_type = cyrus local_recipient_maps = smtpd_use_tls = yes smtp_tls_note_starttls_offer = yes smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem smtpd_tls_loglevel = 1 smtpd_tls_received_header = yes smtpd_tls_session_cache_timeout = 3600s tls_random_source = dev:/dev/urandom ######## Then: vi master.cf Paste under smtp: smtps inet n - n - - smtpd -o smtpd_sasl_auth_enable=yes -o smtpd_reject_unlisted_sender=yes -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject -o broken_sasl_auth_clients=yes Check the smtpd.conf file and amend it: locate smtpd.conf Delete the contents of the file and paste into it: pwcheck_method: saslauthd mech_list: plain login To check the SASL available mechanisms run: saslauthd -V Set SASL authentication to start at system boot: chkconfig --levels 235 saslauthd on Set up the encryption keys: mkdir /etc/postfix/ssl Set up the client certificate for importing into Internet Explorer (for Outlook) / Thunderbird (this will suppress warnings about using a self signed certificate): openssl pkcs12 -export -in smtpd.crt -inkey smtpd.key -out OutlookSMTP.p12 Reload the config: postfix reload Finally insert a relevant iptables rule to access from outside using your firewall script: $IPTABLES -A INPUT -i $EXTIF -p tcp -s $UNIVERSE -d $EXTIP --destination-port 465 -j ACCEPT Or if your mail server is behind a firewall (Assuming the LAN address of your server is 10.10.1.4), add these rules on your firewall: $IPTABLES -A FORWARD -i $EXTIF -p tcp --dport 465 -d 10.10.1.4 -o $INTIF -j ACCEPT $IPTABLES -A FORWARD -o $EXTIF -p tcp --sport 465 -s 10.10.1.4 -i $INTIF -j ACCEPT $IPTABLES -t nat -A PREROUTING -i $EXTIF -p tcp -d $EXTIP2 --dport 465 -j DNAT --to 10.10.1.4:465 Done!
TestingCheck if the port is listening: netstat -ntpl | grep master tcp
0
0 127.0.0.1:10025
0.0.0.0:*
LISTEN 8366/master Test if TLS and AUTH is working: telnet localhost 465 [root@ls1 postfix]#
telnet localhost 465 To test further create an account and attain the Base64 Mime password with mmencode or the following perl script: #!/usr/bin/perl
use strict;
use MIME::Base64;
if ( $#ARGV !=1) {
die "Usage: encode_sasl_plain.pl <username> <password>n";
}
print encode_base64("$ARGV[0]?$ARGV[0]?$ARGV[1]");
exit 0;
Generate the Mime password: encode_sasl_plain.pl <username> <password> Y2FtZXJvbnMAY2FtZXJvbnMAdGVzdGluZzA4 telnet localhost 465 Trying 127.0.0.1... **If the authentication is not successful, you may have to change the MECH value in /etc/sysconfig/saslauthd and /etc/init.d/saslauthd. Possible values are listed with the command saslauthd -V and restart saslauthd: /etc/init.d/saslauthd restart Test the connection from outside: telnet yourserver 465 cameron@cs:~$ telnet yourserver 465 To test further, set up an account in Evolution / Thunderbird / Outlook and test the SMTP with the username and password you set up earlier. Remember that because you are using a self signed certifcate, your email client will prompt you each time about an untrusted certificate so you can use the client certificate you created to suppress these warnings. For Thunderbird, if you are really lazy you can even install this addon.
|
Join the discussion.
www.seamlessenterprise.com
IP Convergence
Integrate your wireless and wireline networks.
Learn how from the experts at Sprint.
www.seamlessenterprise.com
Wireless & Wireline Integration
Thoughts, strategies and solutions: join the discussion
www.seamlessenterprise.com
Unified Communications 2009
Join the Discussion. Now.
www.seamlessenterprise.com







Recent comments
21 hours 5 min ago
22 hours 33 min ago
1 day 2 hours ago
1 day 5 hours ago
1 day 7 hours ago
1 day 8 hours ago
1 day 8 hours ago
1 day 9 hours ago
1 day 10 hours ago
1 day 11 hours ago