Showing posts with label postfix. Show all posts
Showing posts with label postfix. Show all posts

Tuesday, June 15, 2010

second postfix instance with auth smtp

See advosys.ca help.ubuntu.com adomas.org postfix.org

Copy config dir
cp -rp /etc/postfix /etc/postfix-out

Create file /etc/postfix-out/sasl/smtpd.conf with
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN

Note, that previous plaintext mechanism send credentials unencrypted. Therefore TLS-encrypted SMTP session is used.

Add following lines to /etc/postfix-out/main.cf
queue_directory = /var/spool/postfix-out
data_directory = /var/lib/postfix-out


Create and copy queue and data directories
mkdir /var/spool/postfix-out
postfix -c /etc/postfix-out check
cp -rp /var/lib/postfix /var/lib/postfix-out
cp -rp /var/spool/postfix/etc /var/spool/postfix-out
cp -rp /var/spool/postfix/usr /var/spool/postfix-out
cp -rp /var/spool/postfix/lib /var/spool/postfix-out


Add following line to /etc/postfix/main.cf
alternate_config_directories = /etc/postfix-out

Modify port no. for smtp at /etc/postfix-out/master.cf

1025 inet n - - - - smtpd


Test start
postfix -c /etc/postfix-out start

Install sasl and mkdir var folder
apt-get install libsasl2-2 sasl2-bin


Modify /etc/init.d/saslauthd
PIDFILE=/var/spool/postfix-out/var/run/saslauthd/saslauthd.pid

Modify /etc/default/saslauthd
START=yes
PWDIR="/var/spool/postfix-out/var/run/saslauthd"
PARAMS="-m ${PWDIR}"
PIDFILE="${PWDIR}/saslauthd.pid"
OPTIONS="-c -m /var/spool/postfix-out/var/run/saslauthd"


Create dirs for sasl in chroot postfix
dpkg-statoverride --force --update --add root sasl 755 /var/spool/postfix-out/var/run/saslauthd

Add following lines to /etc/postfix-out/main.cf
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_path = smtpd


Restart all services
/etc/init.d/saslauthd restart
/etc/init.d/postfix restart
postfix -c /etc/postfix-out stop
postfix -c /etc/postfix-out start


Test by sasl
testsaslauthd -u USERNAME -p PASSWORD -f /var/spool/postfix-out/var/run/saslauthd/mux

Test by telnet
telnet SERVER_ADDRESS 1025
Trying IPADDRESS...
Connected to SERVER_NAME.
Escape character is '^]'.
220 SERVERNAME ESMTP Postfix (Ubuntu)
ehlo localhost
250-SERVERNAME
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN


Create startup script
cp /etc/init.d/postfix /etc/init.d/postfix-out

And replace pairs in new file
/etc/postfix by /etc/postfix-out
postfix by postfix -c /etc/postfix-out
/var/spool/postfix by /var/spool/postfix-out
postconf by postconf -c /etc/postfix-out

Now make symlinks in rc.d to /etc/init.d/postfix-out, e.g.
ln -s /etc/init.d/postfix-out /etc/rc6.d/K01postfix-out

Tuesday, November 10, 2009

migration openwebmail auth_unix to auth_pam

Motivation: Create new server with openwebmail and authentification to Active Directory (AD). Old server has local hand-made copies of accounts from AD. We need to migrate inboxes, ~/mail/, ~/.openwebmail/ and aliases.

Solution: We used ubuntu server 9.10, likewise and openwebmail 2.53.

Install Ubuntu server 9.10 and checked mail server and ssh server. Setup interfaces. Install few packages:
sudo aptitude install likewise-open libauthen-pam-perl libconvert-asn1-perl libmd5-perl libnet-ldap-perl perl-suid wwwconfig-common libpg-perl apache2 libdbd-mysql-perl alpine ispell iczech language-support-cs language-pack-cs-base gcc linux-headers-$(uname -r) vlan nmap mc

Join domain with likewise (see ubuntu forum), not necessary as Administrator (user):
sudo domainjoin-cli join DOMAIN user
test join:
sudo domainjoin-cli query
Many problems appear due to setting of /etc/resolv.conf, you should choose some AD machine as nameserver

Setup apache (enable ssl):
sudo a2enmod ssl
sudo /etc/init.d/apache2 restart
sudo ln -s /etc/apache2/sites-available/default-ssl /etc/apache2/sites-enabled/000-default-ssl
sudo /etc/init.d/apache2 restart


Setup likewise, enable logging:
sudo vim /etc/samba/lwiauthd.conf
add lines
winbind use default domain = yes
log level = 10


Wget, install and setup openwebmail:
wget http://openwebmail.org/openwebmail/download/debian/owm2.53-2.deb
sudo dpkg -i owm2.53-2.deb
sudo mv /var/www/openwebmail/redirect.html /var/www/index.html
sudo vim /etc/openwebmail/openwebmail.conf

* change lines to
domainnames DOMAIN
auth_module auth_pam.pl
allowed_autologinip all

* comment lines
default_style
forced_moveoldmsgfrominbox yes

* add lines
create_syshomedir yes
quota_module quota_du.pl
quota_limit 180000
quota_treshold 200000
default_language cz
default_moveoldmsgfrominbox no
spellcheck /usr/bin/ispell -a -S -w "-" -d @@@DICTIONARY@@@ -p @@@PDICNAME@@@
spellcheck_pdicname .ispell_words
spellcheck_dictionaries czech, english, american


Repair utf-8 use in perl (see acatysmoof):
sudo vim /usr/share/perl/5.10.0/CGI.pm
change line
my $utf8 = $charset eq 'utf-8';
to
my $utf8 = 0;

Setup postfix:
sudo vim /etc/postfix/main.cf
add line:
mydomain = DOMAIN
restart
sudo /etc/init.d/postfix restart

Move script:
root@cattom1:/home/pvl# cat ./moveusers.sh
#!/bin/sh
UCTY="movelist.txt"
scp -P 22 root@OLDSERVER:/etc/aliases ./old_aliases
cat $UCTY | while read LINE; do
# home move
scp -r -P 22 root@OLDSERVER:/home/$LINE /home/DOMAIN/
cat old_aliases | grep $LINE >> /etc/aliases
chown -R $LINE:domain^users /home/DOMAIN/$LINE
# inboxes
scp -P 22 root@OLDSERVER:/home/mail/$LINE /var/mail/
chown $LINE:mail /var/mail/$LINE
done


Alternativities: diretly to ldap developer.novel