Virtual Mail And FTP Hosting With iRedMail And Pure-FTPd On FreeBSD

iRedMail is a shell script that lets you quickly deploy a full-featured mail solution in less than 2 minutes. Since version 0.6, it supports FreeBSD 7.2 and 8.0 (both i386 and x86_64). iRedMail supports both OpenLDAP and MySQL as backends for storing virtual domains and users.

The OpenLDAP backend of iRedMail allows you to integrate all kinds of applications. This guide shows you how to integrate pure-ftpd into the iRedMail ldap backend on FreeBSD 7.2, passwords will be stored in ldap and you can change the password through webmail.

This tutorial is based on FreeBSD 7.2, so I suggest you set up a minimum FreeBSD 7.2 , install iredmail 0.60 and choose openldap as backend, ss shown in these tutorials:

 

1 Install Pure-FTPd

Install pure-ftpd:

# cd /usr/ports/ftp/pure-ftpd/
# make install clean

Options for Pure-ftpd, the LDAP must be select:

 

2 Add FTP User

When you install pureftp, an ftp group is created, but no ftp user; this results in the error "mail pure-ftpd:(?:?) [ERROR] Unable to find the 'ftp' account". So we need to manually create the ftp user.

# pw useradd ftp -u 14 -g 14 -s /sbin/nologin -d /dev/null
# cat /etc/passwd | grep ftp
ftp:*:14:14:User &:/dev/null:/sbin/nologin
# cat /etc/group | grep ftp
ftp:*:14:

 

3 Configure Pure-ftpd

Create pure-ftp config files:

# cd /usr/local/etc 
# cp pure-ftpd.conf.sample pure-ftpd.conf
# cp pureftpd-ldap.conf.sample pureftpd-ldap.conf
# chmod 644 pure-ftpd.conf
# chmod 644 pureftpd-ldap.conf
# echo 'pureftpd_enable="YES"' >> /etc/rc.conf

Edit pure-ftpd.conf , let pure-ftpd support ldap:

LDAPConfigFile              /usr/local/etc/pureftpd-ldap.conf
CreateHomeDir               yes

 

3.1 Find cn=vmail password

The vmail password was randomly created during iredmail install. You can find the password in /usr/local/etc/postfix/ldap_virtual_mailbox_domains.cf:

cat /usr/local/etc/postfix/ldap_virtual_mailbox_domains.cf
bind_dn         = cn=vmail,dc=example,dc=com
bind_pw         = kZ6uB29mViWKWI9lOH3cGnF7z3Dw3B #cn=vmail password

 

3.2 Edit pureftpd-ldap.conf

LDAPServer localhost
LDAPPort 389
LDAPBaseDN o=domains,dc=example,dc=com
LDAPBindDN cn=vmail,dc=example,dc=com
LDAPBindPW kZ6uB29mViWKWI9lOH3cGnF7z3Dw3B #cn=vmail password
LDAPDefaultUID 1002      # <- UID of 'vmail' user.
LDAPDefaultGID 1002      # <- GID of 'vmail' user.
LDAPFilter (&(objectClass=PureFTPdUser)(mail=\L)(FTPStatus=enabled))
LDAPHomeDir FTPHomeDir  # <- This is new attribute, we will add it
LDAPVersion 3

 

3.3 Get Pure-ftpd Schema

Download the schema that has been modified by iredmail:

wget http://iredmail.googlecode.com/svn/trunk/extra/pureftpd.schema -P /usr/local/etc/openldap/schema/

 

3.4 Edit /usr/local/etc/openldap/slapd.conf

Include pureftpd.schema after iredmail.schema:

include /usr/local/etc/openldap/schema/iredmail.schema
include /usr/local/etc/openldap/schema/pureftpd.schema    # <-- Add this line.

Add index for attributes defined in pureftpd.schema:

# Default index.
#
index objectClass                                   eq,pres
index ou,cn,mail,surname,givenname,telephoneNumber  eq,pres,sub
index uidNumber,gidNumber,loginShell                eq,pres
index uid,memberUid                                 eq,pres,sub
index nisMapName,nisMapEntry                        eq,pres,sub
# <-- Add the below
#Index for FTP attrs.
index FTPQuotaFiles,FTPQuotaMBytes eq,pres
index FTPUploadRatio,FTPDownloadRatio eq,pres
index FTPUploadBandwidth,FTPDownloadBandwidth eq,pres
index FTPStatus,FTPuid,FTPgid,FTPHomeDir eq,pres

 

4 Create FTP Home Dir

FTP data are all stored in the /home/ftp/ directory. Create /home/ftp/, owner must be the root user.

# mkdir /home/ftp/
# ls -dl /home/ftp/
drwxr-xr-x 2 root wheel 512 Jan 31 13:25 /home/ftp/
Share this page:

1 Comment(s)