Enjoy Slackware 15.0!

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revision Both sides next revision
howtos:network_services:postfix_with_cyrus [2013/07/21 11:41 (UTC)]
badirca created
howtos:network_services:postfix_with_cyrus [2017/10/18 09:54 (UTC)]
klaatu old revision restored (2016/06/21 09:54 (UTC))
Line 11: Line 11:
  
   # cd /tmp   # cd /tmp
-  # mkdir cyrus-sal+  # mkdir cyrus-sasl
   # cd cyrus-sasl   # cd cyrus-sasl
   # wget ftp://ftp.slackware.com/pub/slackware/slackware64-13.37/source/n/cyrus-sasl/cyrus-sasl-2.1.23.tar.xz   # wget ftp://ftp.slackware.com/pub/slackware/slackware64-13.37/source/n/cyrus-sasl/cyrus-sasl-2.1.23.tar.xz
Line 57: Line 57:
   # installpkg /tmp/postfix-2.8.3-x86_64-1_SBo.tgz    # installpkg /tmp/postfix-2.8.3-x86_64-1_SBo.tgz 
  
-Before we continue with installation of Imap server we need to assure that Postfix is working and we can authenticate with sasl. Let's make some basic Postfix configuration and some basic SASL configuration. I will be explaining plain auth because later on we will use it togheter with sasl to authenticate.+Before we continue with installation of IMAP server we need to assure that Postfix is working and we can authenticate with sasl. Let's make some basic Postfix configuration and some basic SASL configuration. I will be explaining plain auth because later on we will use it togheter with SASL to authenticate.
  
-First of all we need to make our aliases and tell postfix to use aliases maps from /etc/postfix/aliases, so :+First of all we need to make our aliases and tell Postfix to use aliases maps from /etc/postfix/aliases, so :
  
   # joe /etc/postfix/main.cf   # joe /etc/postfix/main.cf
Line 72: Line 72:
   # adduser   # adduser
      
-  Login name for new user []:xxxxxx+  Login name for new user []: slackware_user
   User ID ('UID') [ defaults to next available ]: press ENTER   User ID ('UID') [ defaults to next available ]: press ENTER
   Initial group [ users ]: 200   Initial group [ users ]: 200
Line 79: Line 79:
   Do you wish to change the sheel? (Y/n): n   Do you wish to change the sheel? (Y/n): n
   Expiry date (YYYY-MM-DD) []: press ENTER   Expiry date (YYYY-MM-DD) []: press ENTER
-  Press ENTER and imput full name and other account relates stuff. Also specify an password for your newly created user.  +  Press ENTER and imput full name and other account relates stuff. Also specify an password for your newly created user. 
 +   
 +Now edit /etc/postfix/aliases and modifiy it to your needs : 
  
 +  root  :         slackware_user
 +  office:   slackware_user
 +  
 +Now update your aliases database issuing the command :
  
 +  # postalias hash:/etc/postfix/aliases   
 +It is now time to make our important configurations for Postfix in order for it to run. 
 +  # joe /etc/postfix/main.cf
 +  myhostname = mx.yourdomain.tld
 +  mydomain = yourdomain.tld 
 +  myorigin = $mydomain
 +  inet_interfaces = all
 +  mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
 +  mynetworks = 127.0.0.0/8
 +Let's now configure Postfix to authenticate users using SASL
 +  # mkdir /etc/sasl2
 +  # cd /etc/sasl2
 +  # touch smtpd.conf
 +  # joe smtpd.conf 
  
 +  pwcheck_method: saslauthd
 +  mech_list: PLAIN LOGIN
 +Now let's configure Postfix to have users authenticate using SASL. Edit /etc/postfix/main.cf and add the folowing code to the end of the file :
 +  smtpd_sasl_auth_enable = yes   
 +  broken_sasl_auth_clients = yes  
 +  smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
 +Let's start the daemons and test our configurations until now:
 +  # saslauthd -a shadow
 +  # postfix start
 +Then from another machine telnet into your mail server on port 25 and issue the following commands :
 +  # telnet mx.mailserver.com 25
 +  ehlo user.mailserver.tld   
 +  250-mx.mailserver.com
 +  250-PIPELINING
 +  250-SIZE 10240000
 +  250-VRFY
 +  250-ETRN
 +  250-AUTH PLAIN LOGIN
 +  250-AUTH=PLAIN LOGIN
 +  250-ENHANCEDSTATUSCODES
 +  250-8BITMIME
 +  250 DSN
 +  AUTH PLAIN Y4R0QYxpcuHsFBRbbGjnPHIwYjB0MWrpMTk7La==
 +  235 2.7.0 Authentication successful
 +  MAIL FROM: <user@mailserver.com>
 +  250 2.1.0 Ok
 +  RCPT TO: <user@yahoo.com>
 +  250 2.1.5 Ok
 +  DATA
 +  354 End data with <CR><LF>.<CR><LF>
 +  HI. This mail is a test .
 +  .
 +  250 2.0.0 Ok: queued as 4C0EE221E93
 +  QUIT
 +<note>In order to find out the string after AUTH PLAIN enter the command ''printf 'user\0user\0password' | mmencode'' on your mail server, where user is your username and password is your password</note>  
 +<note important>Rember to put the "." at the end so the mail can be sent to qeue daemon </note>  
 +====== Installing Mail Delivery and Cyrus IMAP ======
  
 +  # cd /tmp
 +  # mkdir cyrus-imap
 +  # cd cyrus-imap
 +  # wget http://cyrusimap.org/releases/cyrus-imapd-2.4.12.tar.gz
 +  # wget http://slackbuilds.org/slackbuilds/13.37/network/cyrus-imapd/README
 +  # wget http://slackbuilds.org/slackbuilds/13.37/network/cyrus-imapd/README.SLACKWARE
 +  # wget http://slackbuilds.org/slackbuilds/13.37/network/cyrus-imapd/cyrus-imapd.SlackBuild
 +  # wget http://slackbuilds.org/slackbuilds/13.37/network/cyrus-imapd/cyrus-imapd.info
 +  # wget http://slackbuilds.org/slackbuilds/13.37/network/cyrus-imapd/doinst.sh
 +  # wget http://slackbuilds.org/slackbuilds/13.37/network/cyrus-imapd/imapd.conf
 +  # wget http://slackbuilds.org/slackbuilds/13.37/network/cyrus-imapd/patches
 +  # wget http://slackbuilds.org/slackbuilds/13.37/network/cyrus-imapd/rc.cyrus-imapd
 +  # wget http://slackbuilds.org/slackbuilds/13.37/network/cyrus-imapd/slack-desc
 +  # mkdir patches
 +  # cd patches/
 +  # wget http://mirrors.vbi.vt.edu/mirrors/linux/slackbuilds/13.37/network/cyrus-imapd/patches/cyrus-imapd-2.4.4-autocreate-0.10-0-sv1.patch
 +  # wget http://mirrors.vbi.vt.edu/mirrors/linux/slackbuilds/13.37/network/cyrus-imapd/patches/cyrus-imapd-2.4.4-autosieve-0.6.0-sv1.patch
 +  # cd /tmp/cyrus-imap
 +  # groupadd -g 238 cyrus
 +  # useradd -d /var/imap -s /bin/sh -u 238 -g 238 cyrus -G mail 
 +  # sh cyrus-imapd.SlackBuild
 +  # installpkg /tmp/cyrus-imapd-2.4.12-x86_64-1_SBo.tgz
 +  # mkdir -m 750 -p /var/imap /var/spool/imap /var/sieve
 +  # chown cyrus:mail /var/imap /var/spool/imap /var/sieve
 +  # su - cyrus
 +  # /usr/doc/cyrus-imapd-2.4.12/tools/mkimap
 +  # su - root
 +Edit /etc/imapd.conf and add the following lines:
 +  sasl_mech_list: PLAIN LOGIN
 +  allowplaintext: yes  
 +Edit /etc/postfix/main.cf and at mailbox_transport add the following:
 +  mailbox_transport = lmtp:unix:/var/imap/socket/lmtp
 +The last step to do is to add users to your imap server. For that you need to issue these commands :
 +  # passwd cyrus
 +and add a password for cyrus user
 +  # cyradm --user cyrus --server localhost --auth plain    
 +  localhost>cm user.slackware_user 
 +  localhost>lm
 +  localhost> quit
 +<note>slackware_user is the user you have created in your slackware machine</note>  
 +At this point we have an functional Mail Server but with users authenticating in plain text . So the next step is innevitabile.
  
 +====== SSL / TLS Postfix and Cyrus ======
  
 +Let's start by creating our certificates and configuring POSTFIX to use STARTTLS.
 +  # cd /etc/ssl
 +  # misc/CA.pl -newca ( complete all entries)
 +  # openssl req -new -nodes -keyout mailkey.pem -out mailreq.pem -days 36500
 +  # openssl ca -out mail_signed_cert.pem -infiles mailreq.pem
 +  # cp /etc/ssl/mailkey.pem /etc/postfix
 +  # cp /etc/ssl/mail_signed_cert.pem /etc/postfix
 +  # chown root /etc/postfix/mailkey.pem
 +  # chmod 400 /etc/postfix/mailkey.pem
 +  # cp /etc/ssl/demoCA/cacert.pem /etc/postfix
 +Now add the followings to /etc/postfix/main.cf :
 +  smtpd_use_tls = yes
 +  smtpd_tls_key_file = /etc/postfix/mailkey.pem
 +  smtpd_tls_cert_file = /etc/postfix/mail_signed_cert.pem
 +  smtpd_tls_CAfile = /etc/postfix/cacert.pem
 +<note important>In /etc/postfix/master.cf delete the "#" sign from smtps and the next two columns from it
 +                   smtps     inet  n                               smtpd
 +                     -o smtpd_tls_wrappermode=yes
 +                     -o smtpd_sasl_auth_enable=yes
 +</note>
 +Now let's configure IMAP to use STARTTLS
 +  # openssl req -new -nodes -out req.pem -keyout key.pem  
 +  # openssl rsa -in key.pem -out new.key.pem
 +  # openssl x509 -in req.pem -out ca-cert -req -signkey new.key.pem -days 36500
 +  # cp new.key.pem /var/imap/server.pem
 +  # rm new.key.pem
 +  # cat ca-cert >> /var/imap/server.pem
 +  # chown cyrus:mail /var/imap/server.pem
 +  # chmod 600 /var/imap/server.pem 
 +  # echo tls_ca_file: /var/imap/server.pem >> /etc/imapd.conf
 +  # echo tls_cert_file: /var/imap/server.pem >> /etc/imapd.conf
 +  # echo tls_key_file: /var/imap/server.pem >> /etc/imapd.conf 
 +  
 +====== Adding daemons to rc.local ======
 +  
 +Now the last step is to add all daemons to rc.local so they can start when machine boots. So open /etc/rc.d/rc.local and add these lines :
 +  # Starting saslauthd daemon
 +  if [ ! -r /var/state/saslauthd/saslauthd.pid ]; then
 +      echo "Starting SASL authentication daemon:  /usr/sbin/saslauthd -a shadow"
 +      /usr/sbin/saslauthd -a shadow
 +  fi
  
-====== Sources ====== +  # Starting IMAP daemon 
-<!-- If you are copying information from another source, then specify that source --> +  if [ -x /usr/libexec/cyrus/master ]; then 
-<!-- * Original source: [[http://some.website.org/some/page.html]] --> +      echo "Starting Cyrus IMAP daemon /usr/libexec/cyrus/master" 
-<!-- Authors are allowed to give credit to themselves! --> +      /etc/rc.d/rc.cyrus-imapd start 
-<!-- * Originally written by [[wiki:user:xxx | User X]] --> +  fi
-<!-- * Contributions by [[wiki:user:yyy | User Y]] -->+
  
-<!-- Please do not modify anything belowexcept adding new tags.--> +  # Starting POSTFIX daemon 
-<!-- You must remove the tag-word "template" below before saving your new page --> +  /etc/rc.d/rc.postfix start 
-{{tag>howtos template}}+      
 + 
 + 
 + 
 + 
 +====== Sources ====== 
 +  Postfix The Definitive GuideKyle DDent, O'Reilly 
 +  Managing IMAP, Dianna Mullet & Kevin Mullet, O'Reilly 
 +  Official Postfix Documentation, [[http://www.postfix.org/documentation.html]] 
 +{{tag>howtos author_badirca}}

In Other Languages
QR Code
QR Code howtos:network_services:postfix_with_cyrus (generated for current page)