Virtual Mail And FTP Hosting With iRedMail And Pure-FTPd On Debian Lenny - Page 2

Want to support HowtoForge? Become a subscriber!
 
Submitted by eddiechen (Contact Author) (Forums) on Wed, 2009-12-02 18:36. ::

10 Add LDAP Attributes And Values

10.1 Add LDAP Attributes And Values For Existing Mail Users

Use phpLDAPadmin or other tools to add sample LDAP attributes and values for existing mail users.

Attribute Name Value
objectClass PureFTPdUser
FTPStatus enabled
FTPQuotaFiles 50
FTPQuotaMBytes 10
FTPDownloadBandwidth 50
FTPUploadBandwidth 50
FTPDownloadRatio 5
FTPUploadRatio 1
FTPHomeDir /home/ftp/example.com/username/

Log into phpLDAPadmin:

Find the existing mail user www@example.com:

Add Object Class for the user www@example.com:

Select the Object Class PureFTPdUser:

The result:

Add PureFTPdUser attribute:

All the attributes about PureFTPdUser:

Enable FTP status:

Add all the PureFTP attributes according to the below form:

 

10.2 Add LDAP Attributes And Values For New Users

You can use the iredmail tools to quickly create a new user including the PureFTP attributes and values.

cd iRedMail-0.5.1/tools
vi create_mail_user_OpenLDAP.sh

LDAP_SUFFIX="dc=example,dc=com" # <- Change the LDAP suffix
BINDPW='passwd'                 # <- The user cn=manager,dc=example,dc=com password
PUREFTPD_INTEGRATION='YES'      # <- Change form NO to YES,enable the pureftp inteegration

Run the script to create the users user1 and user2. By default, the default password is same as the user name.

bash create_mail_user_OpenLDAP.sh example.com user1 user2

adding new entry "ou=Users,domainName=example.com,o=domains,dc=example,dc=com"
ldapadd: Already exists (68)

adding new entry "ou=Groups,domainName=example.com,o=domains,dc=example,dc=com"
ldapadd: Already exists (68)

adding new entry "ou=Aliases,domainName=example.com,o=domains,dc=example,dc=com"
ldapadd: Already exists (68)

adding new entry "mail=user1@example.com,ou=Users,domainName=example.com,o=domains,dc=example,dc=com"

adding new entry "mail=user2@example.com,ou=Users,domainName=example.com,o=domains,dc=example,dc=com"

 

11 Configure iptables

By default the ports 20 and 21 are not open. If you use the ftp client test, you need open the ports 20 and 21.

vi /etc/default/iptables

# http/https, smtp/smtps, pop3/pop3s, imap/imaps, ssh
-A INPUT -p tcp -m multiport --dport 80,443,25,465,110,995,143,993,587,465,22,20,21 -j ACCEPT # <-- Add 20 21 

Restart the iptables service:

/etc/init.d/iptables restart

 

12 Testing

You can use a Windows FTP client or the Linux ftp client lftp for testing.

lftp localhost
lftp localhost:~> debug 4
lftp localhost:~> login user1@example.com user1 # <-- type in the username and password
lftp user1@example.com@localhost:~> ls

---- Connecting to localhost (127.0.0.1) port 21
<--- 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
<--- 220-You are user number 1 of 50 allowed.
<--- 220-Local time is now 16:25. Server port: 21.
<--- 220-IPv6 connections are also welcome on this server.
<--- 220 You will be disconnected after 15 minutes of inactivity.
<--- 211-Extensions supported:
<--- EPRT
<--- IDLE
<--- MDTM
<--- SIZE
<--- REST STREAM
<--- MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
<--- MLSD
<--- ESTP
<--- PASV
<--- EPSV
<--- SPSV
<--- ESTA
<--- AUTH TLS
<--- PBSZ
<--- PROT
<--- UTF8
<--- 211 End.
<--- 500 This security scheme is not implemented
<--- 200 OK, UTF-8 enabled
<--- 200 MLST OPTS type;size;sizd;modify;UNIX.mode;UNIX.uid;UNIX.gid;unique;
<--- 331 User user1@example.com OK. Password required
<--- 230-Your bandwidth usage is restricted
<--- 230-User user1@example.com has group access to: vmail
<--- 230-You must respect a 1:5 (UL/DL) ratio
<--- 230-OK. Current restricted directory is /
<--- 230-0 files used (0%) - authorized: 50 files
<--- 230 0 Kbytes used (0%) - authorized: 10240 Kb
<--- 257 "/" is your current location
<--- 227 Entering Passive Mode (127,0,0,1,32,58)
<--- 150 Accepted data connection
<--- 226-Options: -l
<--- 226 0 matches total

 

13 Troubleshooting

Enable verbose logging in pure-ftpd:

echo "yes" > /etc/pure-ftpd/conf/VerboseLog

vi /etc/rsyslog.conf

ftp.*                       -/var/log/pure-ftpd/pureftpd.log # <-- Add entry

Create the pureftpd.log file:

touch /var/log/pure-ftpd/pureftpd.log

Eable ldap logging:

vi /etc/ldap/slapd.conf

loglevel    256 # <-- change form 0 to 256  

Restart pure-ftpd, syslog, and openldap:

/etc/init.d/pure-ftpd-ldap restart
/etc/init.d/rsyslog restart
/etc/init.d/slapd restart

Monitor /var/log/pureftpd.log and /var/log/openldap.log for troubleshooting:

tail -0f /var/log/openldap.log

mail:~# tail -0f /var/log/openldap.log
Nov 11 17:42:09 mail slapd[16124]: warning: /etc/hosts.deny, line 0: missing newline or line too long
Nov 11 17:42:09 mail slapd[16124]: conn=5 fd=14 ACCEPT from IP=127.0.0.1:46247 (IP=0.0.0.0:389)
Nov 11 17:42:09 mail slapd[16124]: conn=5 op=0 BIND dn="cn=vmail,dc=example,dc=com" method=128
Nov 11 17:42:09 mail slapd[16124]: conn=5 op=0 BIND dn="cn=vmail,dc=example,dc=com" mech=SIMPLE ssf=0
Nov 11 17:42:09 mail slapd[16124]: conn=5 op=0 RESULT tag=97 err=0 text=
Nov 11 17:42:09 mail slapd[16124]: conn=5 op=1 SRCH base="o=domains,dc=example,dc=com" scope=2
deref=0 filter="(&(objectClass=PureFTPdUser)(mail=user1@example.com)(FTPStatus=enabled))"
Nov 11 17:42:09 mail slapd[16124]: conn=5 op=1 SRCH attr=FTPHomeDir uidNumber
FTPuid gidNumber FTPgid userPassword loginShell FTPStatus FTPQuotaFiles
FTPQuotaMBytes FTPDownloadRatio FTPUploadRatio FTPDownloadBandwidth FTPUploadBandwidth
Nov 11 17:42:09 mail slapd[16124]: conn=5 op=1 SEARCH RESULT tag=101 err=0 nentries=1 text=
Nov 11 17:42:09 mail slapd[16124]: conn=5 op=2 UNBIND
Nov 11 17:42:09 mail slapd[16124]: conn=5 fd=14 closed

tail -0f /var/log/pure-ftpd/pureftpd.log

mail:~# tail -0f /var/log/pure-ftpd/pureftpd.log
Nov 11 17:39:37 mail pure-ftpd: (?@123.114.254.226) [INFO] New connection from 123.114.254.226
Nov 11 17:39:37 mail pure-ftpd: (?@123.114.254.226) [DEBUG] Command [user] [user1@example.com]
Nov 11 17:39:38 mail pure-ftpd: (?@123.114.254.226) [DEBUG] Command [pass] [<*>]
Nov 11 17:39:38 mail pure-ftpd: (?@123.114.254.226) [INFO] user1@example.com is now logged in
Nov 11 17:39:38 mail pure-ftpd: (user1@example.com@123.114.254.226) [DEBUG] Command [syst] []
Nov 11 17:39:39 mail pure-ftpd: (user1@example.com@123.114.254.226) [DEBUG] Command [feat] []
Nov 11 17:39:39 mail pure-ftpd: (user1@example.com@123.114.254.226) [DEBUG] Command [pwd] []
Nov 11 17:39:39 mail pure-ftpd: (user1@example.com@123.114.254.226) [DEBUG] Command [type] [A]
Nov 11 17:39:40 mail pure-ftpd: (user1@example.com@123.114.254.226) [DEBUG] Command [port] [123,114,254,226,17,57]
Nov 11 17:39:40 mail pure-ftpd: (user1@example.com@123.114.254.226) [DEBUG] Command [list] [-a]
Nov 11 17:39:48 mail pure-ftpd: (user1@example.com@123.114.254.226) [DEBUG] Command [type] [I]
Nov 11 17:39:49 mail pure-ftpd: (user1@example.com@123.114.254.226) [DEBUG] Command [port] [123,114,254,226,17,60]
Nov 11 17:39:49 mail pure-ftpd: (user1@example.com@123.114.254.226) [DEBUG] Command [stor] [test.pdf]
Nov 11 17:39:51 mail pure-ftpd: (user1@example.com@123.114.254.226) [NOTICE]
/home/ftp/example.com/u/us/use/user1-2009.11.11.17.22.26/ftp//chenshake.pdf uploaded (14317 bytes, 9.45KB/sec)
Nov 11 17:39:51 mail pure-ftpd: (user1@example.com@123.114.254.226) [DEBUG] Command [type] [A]
Nov 11 17:39:52 mail pure-ftpd: (user1@example.com@123.114.254.226) [DEBUG] Command [port] [123,114,254,226,17,61]
Nov 11 17:39:53 mail pure-ftpd: (user1@example.com@123.114.254.226) [DEBUG] Command [list] [-a]
Nov 11 17:40:24 mail pure-ftpd: (user1@example.com@123.114.254.226) [DEBUG] Command [pwd] []
Nov 11 17:40:34 mail pure-ftpd: (user1@example.com@123.114.254.226) [INFO] Logout.

 

14 Links


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.