Accueil > Informatique > Poweredge T105 > Installation de proftp

Installation de proftp

mardi 26 août 2008, par frederic

comme d’hab :

apt-get install proftpd proftpd-mysql

le lancement se fait par inetd

la création des tables :

CREATE DATABASE `proftpd`;
USE proftpd;

--
-- Table structure for table `ftpgroup`
--
CREATE TABLE `ftpgroup` (
`groupname` varchar(16) NOT NULL DEFAULT '',
`gid` smallint(6) NOT NULL DEFAULT '5500',
`members` varchar(16) NOT NULL DEFAULT '',
KEY `groupname` (`groupname`)
) TYPE=MyISAM COMMENT='Table des groupes ProFTPD';

--
-- Table structure for table `ftpquotalimits`
--
CREATE TABLE `ftpquotalimits` (
`name` varchar(30) DEFAULT NULL,
`quota_type` enum('user','group','class','all') NOT NULL DEFAULT 'user',
`par_session` enum('false','true') NOT NULL DEFAULT 'false',
`limit_type` enum('soft','hard') NOT NULL DEFAULT 'soft',
`bytes_up_limit` float NOT NULL DEFAULT '0',
`bytes_down_limit` float NOT NULL DEFAULT '0',
`bytes_transfer_limit` float NOT NULL DEFAULT '0',
`files_up_limit` int(10) UNSIGNED NOT NULL DEFAULT '0',
`files_down_limit` int(10) UNSIGNED NOT NULL DEFAULT '0',
`files_transfer_limit` int(10) UNSIGNED NOT NULL DEFAULT '0'
) TYPE=MyISAM COMMENT='Table des quotas ProFTPD';

--
-- Table structure for table `ftpquotatotal`
--
CREATE TABLE `ftpquotatotal` (
`name` varchar(30) NOT NULL DEFAULT '',
`quota_type` enum('user','group','class','all') NOT NULL DEFAULT 'user',
`bytes_up_total` float NOT NULL DEFAULT '0',
`bytes_down_total` float NOT NULL DEFAULT '0',
`bytes_transfer_total` float NOT NULL DEFAULT '0',
`files_up_total` int(10) UNSIGNED NOT NULL DEFAULT '0',
`files_down_total` int(10) UNSIGNED NOT NULL DEFAULT '0',
`files_transfer_total` int(10) UNSIGNED NOT NULL DEFAULT '0'
) TYPE=MyISAM COMMENT='Table des compteurs des quotas ProFTPD';

--
-- Table structure for table `ftpuser`
--
CREATE TABLE `ftpuser` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`userid` varchar(32) NOT NULL DEFAULT '',
`passwd` varchar(32) NOT NULL DEFAULT '',
`uid` smallint(6) NOT NULL DEFAULT '5500',
`gid` smallint(6) NOT NULL DEFAULT '5500',
`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`)
) TYPE=MyISAM COMMENT='Table des utlisateurs ProFTPD';

La config de proftp dans le fichier /etc/proftpd/proftpd.conf :

on décommente :

DefaultRoot            ~
RequireValidShell        off
<IfModule mod_sql.c>
  SQLBackend            mysql
</IfModule>

on ajoute à la fin :

# Mod MySQL
# =========
# Les mots de passe sont cryptes dans la base avec la fonction ENCRYPT (MySQL)
SQLAuthTypes Crypt
SQLAuthenticate users* groups*

# Modifiez cette ligne selon l'utilisateur et le mot de passe definit plutot
SQLConnectInfo proftpd@localhost proftpd proftpd

# On donne a ProFTPd le nom des colonnes de la table usertable
SQLUserInfo ftpuser userid passwd uid gid homedir shell
SQLUserWhereClause "LoginAllowed = 'true'"

# On donne a ProFTPd le nom des colonnes de la table "grouptable"
SQLGroupInfo ftpgroup groupname gid members

# Creer le repertoire home de l'utilisateur si il n'existe pas
SQLHomedirOnDemand on

# 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'" ftpuser

#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'" ftpuser

# 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