lunes, 30 de abril de 2007

Bueno con respecto a mi web mail...

todo esto comenzo por que el "buen" zeus queria algo parecido y acudio a mi a ver que podiamos hacer. y como casi siempre lo logre..
he aqui los pasos que segui para realizar lo que ya hacia vario tiempo deseaba hacer!

Postfix With SMTP-AUTH And TLS

apt-get install postfix libsasl2 sasl2-bin libsasl2-modules libdb3-util procmail
le hara dos preguntas a lo que responderas

General type of configuration? <-- Internet Site
Mail name? <-- miserver.midominio.com

el te pone una configuracion default: por lo tanto ejecutamos

dpkg-reconfigure postfix

te hara otras preguntas:

General type of configuration? <-- Internet Site
Where should mail for root go <-- [blank]
Mail name? <-- miserver.midominio.com
Other destinations to accept mail for? (blank for none) <-- miserver.midominio.com, localhost.midominio.com, localhost.localdomain, localhost
Force synchronous updates on mail queue? <-- No
Local networks? <-- 127.0.0.0/8
Use procmail for local delivery? <-- Yes
Mailbox size limit <-- 0
Local address extension character? <-- +
Internet protocols to use? <-- all

luego:

postconf -e 'smtpd_sasl_local_domain ='
postconf -e 'smtpd_sasl_auth_enable = yes'
postconf -e 'smtpd_sasl_security_options = noanonymous'
postconf -e 'broken_sasl_auth_clients = yes'
postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'
postconf -e 'inet_interfaces = all'
echo 'pwcheck_method: saslauthd' >> /etc/postfix/sasl/smtpd.conf
echo 'mech_list: plain login' >> /etc/postfix/sasl/smtpd.conf

luego creamos los certificados para TLS:

mkdir /etc/postfix/ssl
cd /etc/postfix/ssl/
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024

chmod 600 smtpd.key

openssl req -new -key smtpd.key -out smtpd.csr

openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt

openssl rsa -in smtpd.key -out smtpd.key.unencrypted

mv -f smtpd.key.unencrypted smtpd.key
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650

configuramos el Postfix para TLS:

postconf -e 'smtpd_tls_auth_only = no'
postconf -e 'smtp_use_tls = yes'
postconf -e 'smtpd_use_tls = yes'
postconf -e 'smtp_tls_note_starttls_offer = yes'
postconf -e 'smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key'
postconf -e 'smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt'
postconf -e 'smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem'
postconf -e 'smtpd_tls_loglevel = 1'
postconf -e 'smtpd_tls_received_header = yes'
postconf -e 'smtpd_tls_session_cache_timeout = 3600s'
postconf -e 'tls_random_source = dev:/dev/urandom'
postconf -e 'myhostname = miserver.midominio.com'

el archivo /etc/postfix/main.cf deberia parecerse a este:

cat /etc/postfix/main.cf

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

# TLS parameters
smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
smtpd_use_tls = yes
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = miserver.midominio.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = miserver.midominio.com, localhost.midominio.com, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
smtpd_sasl_local_domain =
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_tls_auth_only = no
smtp_use_tls = yes
smtp_tls_note_starttls_offer = yes
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

Reiniciamos Postfix:

/etc/init.d/postfix restart

la autenticacion la realizaremos con saslauthd. cambiaremos unas cositas para que funcione correctamente ya que Postfix corre en /var/spool/postfix, realizaremos lo siguiente:

mkdir -p /var/spool/postfix/var/run/saslauthd

ahora tenemos que esitar /etc/default/saslauthd para activar saslauthd. ponga yes a START y cambie la linea OPTIONS="-c" to OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r":

vi /etc/default/saslauthd

# Settings for saslauthd daemon
#

# Should saslauthd run automatically on startup? (default: no)
START=yes

# Which authentication mechanisms should saslauthd use? (default: pam)
#
# Available options in this Debian package:
# getpwent -- use the getpwent() library function
# kerberos5 -- use Kerberos 5
# pam -- use PAM
# rimap -- use a remote IMAP server
# shadow -- use the local shadow password file
# sasldb -- use the local sasldb database file
# ldap -- use LDAP (configuration is in /etc/saslauthd.conf)
#
# Only one option may be used at a time. See the saslauthd man page
# for more information.
#
# Example: MECHANISMS="pam"
MECHANISMS="pam"

# Additional options for this mechanism. (default: none)
# See the saslauthd man page for information about mech-specific options.
MECH_OPTIONS=""

# How many saslauthd processes should we run? (default: 5)
# A value of 0 will fork a new process for each connection.
THREADS=5

# Other options (default: -c)
# See the saslauthd man page for information about these options.
#
# Example for postfix users: "-c -m /var/spool/postfix/var/run/saslauthd"
# Note: See /usr/share/doc/sasl2-bin/README.Debian
OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r"

ahora iniciamos saslauthd:

/etc/init.d/saslauthd start

para ver si SMTP-AUTH y TLS trabaja crrectamente corremos el siguiente comando:

telnet localhost 25

despues de haber establecido la coneccion a su Postfix mail server, digite:

ehlo localhost

si usted ve las lineas

250-STARTTLS

y

250-AUTH PLAIN LOGIN

todo parece estar bien.

las salidas en mi sistema se miran como estas:

miserver:/etc/postfix/ssl# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
220 miserver.midominio.com ESMTP Postfix (Debian/GNU)
ehlo localhost
250-miserver.midominio.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.

ahora escriba:

quit

regresaremos a la consola
bien ya tendriamos funcionado nuestro mail server, ahora instalamos nuestro courier

Courier-IMAP/Courier-POP3

instalamos con:

apt-get install courier-authdaemon courier-base courier-imap courier-imap-ssl courier-pop courier-pop-ssl courier-ssl gamin libgamin0 libglib2.0-0

nuevamente preguntara:

Create directories for web-based administration ? <-- No
SSL certificate required <-- Ok

configuramos Postfix para que entregue los correos a la carpeta de cada usuario:

postconf -e 'home_mailbox = Maildir/'
postconf -e 'mailbox_command ='

reiniciamos postfix

/etc/init.d/postfix restart

y ya.. eso seria todo para nuestro mail server, ahora es opcional en mi caso lo hice
instalar un entorno para recibir y enviar nuestros correos como squirrelmail

instalamos:
apt-get install squirrelmail

eso seria todo por el momento espero que a alguien le sirva...

No hay comentarios: