====== PROFTPD ======
===== Installation =====
==== Pré-requis ====
Installer les paquetages pré-requis à la compilation de proftpd :
* gcc-4.1.2-44.el5.i386.rpm
* cpp-4.1.2-44.el5.i386.rpm
* glibc-devel-2.5-34.i386.rpm
* glibc-headers-2.5-34.i386.rpm
* libgomp-4.3.2-7.el5.i386.rpm
* kernel-headers-2.6.18-128.el5.i386.rpm
* gcc-c++-4.1.2-44.el5.i386.rpm
* libstdc++-devel-4.1.2-44.el5.i386.rpm
* openssl-devel-0.9.8e-7.el5.i386.rpm
* krb5-devel-1.6.1-31.el5.i386.rpm
* zlib-devel-1.2.3-3.i386.rpm
* e2fsprogs-devel-1.39-20.el5.i386.rpm
* keyutils-libs-devel-1.2-1.el5.i386.rpm
* libselinux-devel-1.33.4-5.1.el5.i386.rpm
* libsepol-devel-1.15.2-1.el5.i386.rpm
* mysql-5.0.45-7.el5.i386.rpm
* perl-DBI-1.52-2.el5.i386.rpm
* mysql-devel-5.0.45-7.el5.i386.rpm
==== Installation ====
Récupérer l'archive de proftpd sur http://www.proftpd.org
Décompresser l'archive :
cd /root
tar xzf proftpd-1.3.2rc4.tar.gz
Installation et compilation de proftpd :
cd /ap01/ftpserver/src/proftpd-1.3.2rc4
CFLAGS=-DHAVE_OPENSSL LIBS=-lcrypto
./configure --prefix=/ap01/ftpserver/appl/proftpd --sysconfdir=/ap01/ftpserver/appl/proftpd/etc --localstatedir=/ap01/ftpserver/appl/proftpd/var --with-modules=mod_tls:mod_sql:mod_sql_mysql --with-includes=/usr/include/mysql:/usr/include/openssl --with-libraries=/usr/lib/mysql:/usr/lib/openssl
make clean
make
make install
===== Configuration =====
==== Configuration basic ====
Exemple d'options pour sécuriser et optimiser le serveur FTP
# Permet de cloisonner les utilisateurs dans leur répertoire :
DefaultRoot ~
# L'utilisateur FTP n'est pas obligé d'avoir un SHELL valide (telque bash, ksh etc...) pour se connecter
RequireValidShell no
# Evite les requetes DNS du serveur et permet donc une authentification plus rapide
IdentLookups off
UseReverseDNS off
# Permet de définir la plage de ports pour les connexion passive
# Plage de port à laisser passer par le FireWall
PassivePorts 49152 49500
# Ceci permet de limiter l'accès FTP à /var/ftp
DenyAll
AllowAll
==== Configuration avec SSL ====
=== Générer le certificat ===
Se positionner dans le répertoire de configuration de proftpd :
cd /usr/local/proftpd/etc
Pour générer le certificat voir : [[openssl#creer_un_certificat_ssl|Créer un certificat SSL avec OpenSSL]]
=== Configuration ===
Ajouter les lignes suivantes dans le fichier de configuration ''/usr/local/proftpd/etc/proftpd.conf'' :
TLSEngine on
TLSLog /var/ftpd/tls.log
# Support both SSLv3 and TLSv1
TLSProtocol SSLv3 TLSv1
# Are clients required to use FTP over TLS when talking to this server?
TLSRequired on
# Mettre TLSRequired off pour autoriser également les connexions non sécurisées.
# Server's certificate
TLSRSACertificateFile /usr/local/proftpd/etc/server.crt
TLSRSACertificateKeyFile /usr/local/proftpd/etc/server.key
# CA the server trusts
#TLSCACertificateFile /etc/ftpd/root.cert.pem
# Authenticate clients that want to use FTP over TLS?
TLSVerifyClient off
# Allow SSL/TLS renegotiations when the client requests them, but
# do not force the renegotations. Some clients do not support
# SSL/TLS renegotiations; when mod_tls forces a renegotiation, these
# clients will close the data connection, or there will be a timeout
# on an idle data connection.
TLSRenegotiate required off
Cette configuration oblige une connexion sécurisée au client.
=== Tester ===
Lancer la commande suivante pour tester :
openssl s_client -connect 127.0.0.1:21 -starttls ftp
Pour tester avec un client sous linux :
# lftp 127.0.0.1
lftp 127.0.0.1:~> set ftp:ssl-force true
lftp 127.0.0.1:~> user userftp
Mot de passe:
Liste des client FTPS et FTPES
* lftp : (disponible dans la plupart des distributions Linux)
* Filezilla : http://filezilla-project.org
* CoreFTP : http://www.coreftp.com
==== Configuration avec Mysql ====
Pour activer proftpd avec Mysql et authentifier les utilisateurs avec un compte de la base de données
AuthOrder mod_sql.c mod_auth_unix.c
SQLEngine on
SQLBackend mysql
SQLAuthenticate user
# Indique le type de mot de passe s'il est clair ou chiffré choix : Plaintext Crypt OpenSSL
SQLAuthTypes OpenSSL
# Auth base Mysql
SQLConnectInfo proftpd@mysqlserver:4020 proftpd password
# SQLUserInfo [ user-table user-name passwd uid gid home-dir shell]
SQLUserInfo users username password uid gid homedir shell
# Activation ou non du compte
#SQLUserWhereClause "LoginAllowed = 'true'"
# Evite affichage nom compte systeme
SQLMinUserUID 700
SQLMinUserGID 700
# Mise a jour droits pendant la session
SQLNegativeCache on
Si le mode **OpenSSL** est choisi pour la directive **SQLAuthTypes** le chiffrement du mot de passe se fera par exemple ainsi :
/bin/echo "{sha256}"$(/bin/echo -n "secret" | openssl dgst -binary -sha256 | openssl enc -base64)
Le résultat de la commande doit être inséré dans le champs mot de passe de la base.
Exemple de configuration pour logguer l'activité dans la base :
SQLNamedQuery R SELECT "max(NbReboot) from reboot"
SQLLog PASS,ERR_PASS updatecount
SQLNamedQuery updatecount UPDATE "count=count+1 WHERE username='%u'" users
SQLLog RETR,ERR_RETR emissions
SQLNamedQuery emissions INSERT "'','%u',now(),now(), '%h','%f', %b,'%r','%s',%P,%R" emissions
SQLLog STOR,ERR_STOR receptions
SQLNamedQuery receptions INSERT "'','%u',now(),now(), '%h','%f', %b,'%r','%s',%P,%R" receptions
SQLLog PASS,ERR_PASS debutconnexions
SQLNamedQuery debutconnexions INSERT "'','%u',now(),now(),NULL,NULL, '%h','%r','%s',%P,%R" connexions
SQLLog EXIT,ERR_EXIT finconnexions
SQLNamedQuery finconnexions UPDATE "DateFinConn=now(),HFinConn=now(), CommandConn='%r', CodeConn='%s' WHERE IdFtpd='%P' AND NbReboot='%R'" connexions
SQLLog MKD,ERR_MKD creationsr
SQLNamedQuery creationsr INSERT "'','%u',now(),now(), '%h','%f','%r','%s',%P,%R" creationsr
SQLLog RMD,ERR_RMD suppressionsr
SQLNamedQuery suppressionsr INSERT "'','%u',now(),now(), '%h','%f','%r','%s',%P,%R" suppressionsr
SQLLog DELE,ERR_DELE suppressionsf
SQLNamedQuery suppressionsf INSERT "'','%u',now(),now(), '%h','%f','%r','%s',%P,%R" suppressionsf
SQLLog RNTO,ERR_RNTO renames
SQLNamedQuery renames INSERT "'','%u',now(),now(), '%h','%f','%r','%s',%P,%R" renames
===== Documentation =====
* http://www.proftpd.org/docs/