Proftpd

    Installation

    aptitude install proftpd

    Notice: Answer standalone mode to the question

    Configuration

    /etc/ptoftpd/proftpd.conf

    DefaultRoot ~
    RequireValidShell off
    ListOptions "-a"
    

    Limit download/upload:

    TransferRate RETR 15.0
    TransferRate STOR 55.0
    

    Note: ko/s

    Permit to continue download/upload:

    AllowRetrieveRestart on
    AllowStoreRestart on
    

    Note: could be usefull after "/etc/init.d/proftpd restart" or a down internet connection

    No SQL Database

    AuthUserFile /etc/proftpd/ftpd.passwd

    Add user :

    ftpasswd --passwd --name=user --uid=1000 --gid=33 --home=/home/user/www --shell=/bin/false --file=/etc/proftpd/ftpd.passwd
    

    SQL Database

    We need to install proftpd-mod-mysql or pgql for postgresql and uncomment in /etc/proftpd/modules.conf.

    /etc/proftpd/sql.conf

    
    `<IfModule mod_sql.c>`
     SQLBackend            mysql
    
     SQLEngine on
    
    # Mod MySQL
    
    # =========
    # Les mots de passe sont cryptes dans la base avec la fonction ENCRYPT (MySQL)
    
    SQLAuthTypes Crypt
    SQLAuthenticate users* groups*
    
    # Connection a la BDD pour les informations
    
    SQLConnectInfo serveur_ftp@localhost serveur_ftp PASSWORD
    
    # On donne a ProFTPd le nom des colonnes de la table usertable
    
    SQLUserInfo users userid passwd uid gid homedir shell
    SQLUserWhereClause "LoginAllowed = 'true'"
    
    # On donne a ProFTPd le nom des colonnes de la table "grouptable"
    
    SQLGroupInfo groups groupname gid members
    SQLDefaultGID 33
    
    # Met a jour les compteurs a chaque connection d'un utilisateur
    
    SQLLog PASS updatecount
    SQLNamedQuery updatecount UPDATE "count=count+1, accessed=now() WHERE userid='%u'" users
    
    #Met a jour les compteurs a chaque upload ou download d'un utilisateur
    
    SQLLog STOR,DELE modified
    SQLNamedQuery modified UPDATE "modified=now() WHERE userid='%u'" users
    
    ## Mod quota
    
    # =========
    #QuotaEngine on
    
    #QuotaDirectoryTally on
    #QuotaDisplayUnits Mb
    
    #QuotaShowQuotas on
    
    ## Definit les requetes SQL pour que ProFTPd recupere les infos sur les quotas
    
    #SQLNamedQuery get-quota-limit SELECT "name, quota_type, par_session, limit_type, bytes_up_limit, bytes_down_limit, bytes_transfer_limit, files_up_limit, files_down_limit, files_transfer_limit FROM ftpquotalimits WHERE name = '%{0}' AND quota_type = '%{1}'"
    #SQLNamedQuery get-quota-tally SELECT "name, quota_type, bytes_up_total, bytes_down_total, bytes_transfer_total, files_up_total, files_down_total, files_transfer_total FROM ftpquotatotal WHERE name = '%{0}' AND quota_type = '%{1}'"
    
    #SQLNamedQuery update-quota-tally UPDATE "bytes_up_total = bytes_up_total + %{0}, bytes_down_total = bytes_down_total + %{1}, bytes_transfer_total = bytes_transfer_total + %{2}, files_up_total = files_up_total + %{3}, files_down_total = files_down_total + %{4}, files_transfer_total = files_transfer_total + %{5} WHERE name = '%{6}' AND quota_type = '%{7}'" ftpquotatotal
    #SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}" ftpquotatotal
    
    #QuotaLimitTable sql:/get-quota-limit
    
    #QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally
    
    
    # Gestion des logs
    
    # ================
    # Enregistre les requetes SQL dans /var/log/proftpd/mysql.log
    
    SQLLogFile /var/log/proftpd/mysql.log
    
    # Enregistre les authentifications
    
    LogFormat auth "%v [%P] %h %t \"%r\" %s"
    ExtendedLog /var/log/proftpd/auth.log AUTH auth
    
    # Enregistre les acces aux fichiers
    
    LogFormat write "%h %l %u %t \"%r\" %s %b"
    ExtendedLog /var/log/proftpd/access.log WRITE,READ write
    
    `</IfModule>`
    

    SQL structure :

    	--
    	-- Table structure for table `groups`
    	--
    
    	CREATE TABLE IF NOT EXISTS `groups` (
    	  `groupname` varchar(16) NOT NULL DEFAULT '',
    	  `gid` smallint(6) NOT NULL DEFAULT '5500',
    	  `members` varchar(16) NOT NULL DEFAULT '',
    	  KEY `groupname` (`groupname`)
    	) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Table des groupes ProFTPD';
    
    
    	-- --------------------------------------------------------
    
    	--
    	-- Table structure for table `users`
    	--
    
    	CREATE TABLE IF NOT EXISTS `users` (
    	  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    	  `userid` varchar(32) NOT NULL DEFAULT '',
    	  `passwd` varchar(3000) NOT NULL,
    	  `uid` smallint(6) NOT NULL DEFAULT '5500',
    	  `gid` smallint(6) NOT NULL DEFAULT '33',
    	  `homedir` varchar(255) NOT NULL DEFAULT '',
    	  `shell` varchar(16) NOT NULL DEFAULT '/bin/false',
    	  `count` int(11) NOT NULL DEFAULT '0',
    	  `accessed` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    	  `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    	  `LoginAllowed` enum('true','false') NOT NULL DEFAULT 'true',
    	  PRIMARY KEY (`id`)
    	) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COMMENT='Table des utlisateurs ProFTPD' AUTO_INCREMENT=12 ;