Ceci est une ancienne révision du document !
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 ./configure --prefix=/usr/local/proftpd --sysconfdir=/usr/local/proftpd/etc --localstatedir=/ap01/ftpserver/appl/proftpd/var --with-modules=mod_tls:mod_sql:mod_sql_mysql --with-includes=/usr/include/mysql --with-libraries=/usr/lib/mysql 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
Se positionner dans le répertoire de configuration apache :
cd /usr/local/proftpd/etc
Lancer la commande pour générer la clé privée RSA :
openssl genrsa -out server.key 1024
A partir de notre clé privée nous allons créer notre fichier de demande de signature (Certificate Signing Request) :
openssl req -new -key server.key -out request.csr
Auto-signer la clé et créer le certificat :
openssl x509 -req -days 365 -in request.csr -signkey server.key -out server.crt
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
SQLEngine on SQLBackend mysql SQLAuthenticate on # Type de cryptage SQLAuthTypes Plaintext Crypt OpenSSL # Auth base Mysql SQLConnectInfo proftpd@mysqlserver 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
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