Installer les paquetages pré-requis à la compilation de proftpd :
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
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 <Directory /> DenyAll </Directory> <Directory /var/ftp> AllowAll </Directory>
Se positionner dans le répertoire de configuration de proftpd :
cd /usr/local/proftpd/etc
Pour générer le certificat voir : Créer un certificat SSL avec OpenSSL
Ajouter les lignes suivantes dans le fichier de configuration /usr/local/proftpd/etc/proftpd.conf
:
<IfModule mod_tls.c> 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 </IfModule>
Cette configuration oblige une connexion sécurisée au client.
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
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