Ayant besoin d’un accès FTP vers mon serveur Debian, je décide d’installer un serveur FTP… mais le quel ?
Les choix sont nombreux, principalement :
Ils semblent tous aussi valables, et si vous parcourez les forums, ou en cherchant sur Google, vous trouverez des personnes conseillant ou déconseillant n’importe le quel de ces serveurs FTP !
J’ai finalement décidé d’installer ProFTP, et cette installation devra permettre à ProFTP de fonctionner en TLS de façon à sécuriser la connexion et que les mots de passe ne circulent pas en clair sur le réseau.Voici différentes documentations trouvées pour ProFTDd sur le Web :
- Setting up an FTP server on Debian : je suivrai ces explications
- Proftp Server Configuration in Debian
- FTP Server setup with TLS (Transport Layer Security) on Debian
- Settingup an FTP Server on Ubuntu with ProFTPD
- Serveur FTP : PROFTPD
- List of directives
L’installation est assez classique, ProFTPd se trouvant dans la liste des packages Debian. En Ubuntu, et dans la majorité des distributions également. En Ubuntu, utilisez « sudo » devant vos commandes système.
A la question « Run proftpd from inetd or standalone? », il est préférable de répondre « standalone »
$ su -
Password:
:~$ aptitude install proftpd
Reading package lists... Done Building dependency tree... Done Reading extended state information Initializing package states... Done Reading task descriptions... Done Building tag database... Done The following NEW packages will be installed:
proftpd 0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 855kB of archives. After unpacking 2720kB will be used. Writing extended state information... Done Get:1 http://mir1.ovh.net etch/main proftpd 1.3.0-19etch2 [855kB] Fetched 855kB in 0s (3060kB/s) Preconfiguring packages ... Selecting previously deselected package proftpd. (Reading database ... 32752 files and directories currently installed.) Unpacking proftpd (from .../proftpd_1.3.0-19etch2_amd64.deb) ... Setting up proftpd (1.3.0-19etch2) ... Adding system user `proftpd' (UID 109) ... Adding new user `proftpd' (UID 109) with group `nogroup' ... Not creating home directory `/var/run/proftpd'. Adding system user `ftp' (UID 110) ... Adding new user `ftp' (UID 110) with group `nogroup' ... Creating home directory `/home/ftp' ... `/usr/share/proftpd/templates/welcome.msg' -> `/home/ftp/welcome.msg.proftpd-new' Starting ftp server: proftpd - IPv6 getaddrinfo 'azerty.monserveur.com' error: Name or service not known .
Visiblement ProFTPd essaye de démarrer un service FTP également en IPv6.
Arrêtons ProFTPd pour vérifier sa configuration :
$ /etc/init.d/proftpd stop
Stopping ftp server: proftpd.
La configuration de ProFTPd se trouve dans :
$ vi /etc/proftpd/proftpd.conf
Désactivons l’IPv6 (si votre serveur est correctement configuré pour l’ IPv6, laissez le actif).
# Set off to disable IPv6 support which is annoying on IPv4 only boxes.
UseIPv6 off
Il est possible d’autoriser le logon « anonymous » en décommentant les lignes en fin du fichier de configuration. Ce n’est PAS du tout conseillé, sauf si votre serveur est un FTP grand publique.
J’ai réduit le nombre maximum de connexions FTP simultanées. 30 est trop élevé dans notre cas, le FTP étant exeptionel. J’ai réduit à 8 :
MaxInstances 8
Il est conseillé de ne pas permettre à tous les utilisateurs de se promener (lire et écrire) dans tous vos dossiers et fichiers !
Pour restreindre l’accès au dossier « Home » de chaque utilisateur et pour que Pro-FTPd fasse automatiquement un « chroot » sur le dossier de l’utilisateur, ajoutez ces lignes dans le fichier de configuration :
# Dossier par défaut (chroot ProFTPd) DefaultRoot ~Sécurité : configuration du TLS (fortement conseillé)
Pour configuré le TLS, il faut d’abord générer un certificat (ou le demander à votre fournisseur de CA : Verisign, etc…). Vous pouvez le générer vous-même.
Si ce n’est pas encore fait, installer OpenSSL :
aptitude install openssl
Il faut créer un certificat SSL pour utiliser TLS. Je le place dans un sous-dossier /etc/proftpd/ssl :
$ mkdir /etc/proftpd/ssl
$ cd /etc/proftpd/ssl/
$ openssl req -new -x509 -days 365 -nodes -out /etc/proftpd/ssl/proftpd.cert.pem -keyout /etc/proftpd
Generating a 1024 bit RSA private key .....................++++++ ............................++++++ writing new private key to '/etc/proftpd/ssl/proftpd.key.pem' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:BE State or Province Name (full name) [Some-State]:Belgium Locality Name (eg, city) []:Brussels Organization Name (eg, company) [Internet Widgits Pty Ltd]:Henri Dupont Organizational Unit Name (eg, section) []: Common Name (eg, YOUR name) []:ftp.dupont.com Email Address []:henri@dupont.com
$ ls -l -rw-r--r-- 1 root root 1314 2009-08-23 07:07 proftpd.cert.pem -rw-r--r-- 1 root root 887 2009-08-23 07:07 proftpd.key.pem
Il faut maintenant configurer ProFTPd pour utiliser ce certificat et fonctionner avec TLS.
$ vi /etc/proftpd/proftpd.conf
Remplacez ces lignes dans la configuration de ProFTPd :
<IfModule mod_tls.c>
TLSEngine off
</IfModule>
par la configuration suivante :
<IfModule mod_tls.c>
TLSEngine on
TLSLog /var/log/proftpd/tls.log
TLSProtocol SSLv23
TLSOptions NoCertRequest
TLSRSACertificateFile /etc/proftpd/ssl/proftpd.cert.pem
TLSRSACertificateKeyFile /etc/proftpd/ssl/proftpd.key.pem
TLSVerifyClient off
TLSRequired on
</IfModule>
La variable TLSProtocol permet de choisir, soit SSLv23 qui autorise à la fois le SSLv3 et le TLSv1 (TLS est préférable car plus sécurisé).
La variable TLSRequired, si à « on », bloque l’accès au client qui ne sont pas en SSL ou TLS !
Si vous voulez que le « simple » FTP non sécurisé soit encore possible, mettez cette variable à « off ».
Sauvez ( :wq en Vi) et redémarrez ProFTPd :
$ /etc/init.d/proftpd start
Starting ftp server: proftpd.
Vous pouvez faire un essais en vous connectant avec un client FTP qui supporte le SSL ou le TLS.
Vérifiez dans les logs si le SSL a bien fonctionné :
$ less /var/log/proftpd/tls.log
Aug 23 07:25:13 mod_tls/2.1.1[17124]: using default OpenSSL verification locations (see $SSL_CERT_DIR environment variable) Aug 23 07:25:13 mod_tls/2.1.1[17124]: TLS/TLS-C requested, starting TLS handshake Aug 23 07:25:13 mod_tls/2.1.1[17124]: TLSv1/SSLv3 connection accepted, using cipher DHE-RSA-AES256-SHA (256 bits) Aug 23 07:25:13 mod_tls/2.1.1[17124]: Protection set to Private Aug 23 07:25:13 mod_tls/2.1.1[17124]: starting TLS negotiation on data connection Aug 23 07:25:13 mod_tls/2.1.1[17124]: TLSv1/SSLv3 data connection accepted, using cipher DHE-RSA-AES256-SHA (256 bits) Aug 23 07:25:26 mod_tls/2.1.1[17126]: using default OpenSSL verification locations (see $SSL_CERT_DIR environment variable) Aug 23 07:25:26 mod_tls/2.1.1[17126]: TLS/TLS-C requested, starting TLS handshake Aug 23 07:25:26 mod_tls/2.1.1[17126]: TLSv1/SSLv3 connection accepted, using cipher DHE-RSA-AES256-SHA (256 bits) Aug 23 07:25:26 mod_tls/2.1.1[17126]: Protection set to Private ...
Le SSL/TLS est bien obligatoire dans ma configuration (option « TLSRequired on »).
Si j’essaye de me connecter avec un client sans utiliser SSL, j’obtiens un message d’erreur :
Warning: ftp_login() [function.ftp-login]: SSL/TLS required on the control channel in /home/didier/...
Le message d’erreur varie en fonction de votre client, mais dans mon cas, il est très clair « SSL/TLS required » !

Les logs de ProFTPd vont dans /var/log/proftpd.
Il est intéressant d’utiliser Logrotate pour les faire tourner tous les jours :
$ vi /etc/logrotate.d/proftpd
/var/log/proftpd/*.log {
missingok
notifempty
postrotate
/usr/bin/kill -HUP `cat /var/run/proftpd.pid 2>/dev/null` 2>/dev/null || true
endscript
}
Je dois encore vérifier demain, si le logrotate fonctionne correctement



















[...] un billet précédent, je décrivais l’installation de ProFTPd. Faute de temps, je n’avais pas encore fait tous les essais [...]
5 septembre 2009 at 16:07[...] J’ai installé ProFTPd sur notre serveur Debian Etch 4.0 (voir mon billet du 23 août). [...]
8 septembre 2009 at 0:10[...] avoir installé et testé ProFTPd sur un serveur Debian, j’ai également besoin d’un serveur FTP sur le serveur Ubuntu [...]
9 septembre 2009 at 1:24[...] This post was Twitted by funwithlinux [...]
3 octobre 2009 at 9:13