Installer un serveur de fichiers FTP (ProFTPD)



Logiciels

ProFTPD

ProFTPDhttp://www.proftpd.org/
ProFTPD 1.2.1 -- 01 mars 2001, 556 ko (.tar.gz), 460 ko (.tar.bz2)
ProFTPD 1.2.2rc3 -- 20 juin 2001, 575 ko (.tar.gz), 475 ko (.tar.bz2)

ProFTPD est un démon FTP pour Un*x et les systèmes d'exploitation de type Un*x. ProFTPD est développé, publié et distribué sous les termes de la licence GNU GPL, ce qui en fait un logiciel libre. Cela signifie qu'il peut être vendu, licencié et manipulé comme vous le souhaitez tant que la totalité des codes sources accompagne n'importe quels paquets ProFTPD, soit, soit disponibles sur n'importe ou tout les sites qui distribuent des binaires pre-compilés. Ce logiciel peut être modifié par n'importe qui à n'importe quelle moment, tant que tout les travaux dérivés sont aussi licencié sous la licence GNU GPL.

Installation

Compilez et installez ProFTPD.
$ lynx ftp://ftp.proftpd.org/distrib/proftpd-1.2.2rc3.tar.gz
$ tar xvzf proftpd-1.2.2rc3.tar.gz
$ cd proftpd-1.2.2rc3
$ CFLAGS='-O2 -s' ./configure --prefix=/usr/local \
  --sysconfdir=/usr/local/etc --mandir=/usr/local/share/man --enable-autoshadow \
  --with-modules=mod_linuxprivs:mod_tar:mod_pam:mod_ratio:mod_readme
$ make
$ make install
$ cd ..
$ rm -rf proftpd-1.2.2rc3

Configuration

proftpd.conf

# This is a basic ProFTPD configuration file (rename it to 
# 'proftpd.conf' for actual use.  It establishes a single server
# and a single anonymous login.  It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.

ServerName			"ProFTPD Default Installation"
ServerType			inetd
DefaultServer			on

# Port 21 is the standard FTP port.
Port				21

# Set the user and group that the server normally runs at.
User				nobody
Group				nogroup

# To prevent DoS attacks, set the maximum number of child processes
# to 30.  If you need to allow more than 30 concurrent connections
# at once, simply increase this value.  Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd)
MaxInstances			30

# Set the maximum number of seconds a data connection is allowed
# to "stall" before being aborted.
TimeoutStalled			300

# We want 'welcome.msg' displayed at login, and '.message' displayed
# in each newly chdired directory.
DisplayLogin			welcome.msg
DisplayFirstChdir		.message

# if you don't want normal users logging in at all, uncomment this
# newt section
#<Limit LOGIN>
#   DenyAll
#</Limit>

# Umask 022 is a good standard umask to prevent new files and dirs
# (second parm) from being group and world writable.
Umask				022 022

# Normally, we want files to be overwriteable.
<Directory /*>
    AllowOverwrite		on
</Directory>

# A basic anonymous configuration, including a single upload directory ("incoming")
<Anonymous ~ftp>

    # Allow logins if they are disabled above.
    <Limit LOGIN>
	AllowAll
    </Limit>

    User			ftp
    Group			ftp
    # We want clients to be able to login with "anonymous" as well as "ftp"
    UserAlias			anonymous ftp

    # Limit the maximum number of anonymous logins with message
    MaxClients			10 "Sorry, max %m users -- try again later"

    # Limit WRITE everywhere in the anonymous chroot
    <Limit WRITE>
	DenyAll
    </Limit>
    
    # An upload directory that allows storing files but not retrieving
    # or creating directories.
    <Directory incoming/*>
	<Limit READ>
	    DenyAll
	</Limit>
	
	<Limit STOR>
	    AllowAll
	</Limit>
    </Directory>

</Anonymous>

Sécurité

Les administrateurs systèmes utilisent souvent ce protocole pour les comptes d'utilisateurs anonymes qui n'ont pas besoin d'être protégés par mot de passe. FTP permet à la plupart des utilisateurs, y compris les pirates, d'accéder à un système. Une fois à l'intérieur, les pirates peuvent facilement se frayer un chemin à travers le réseau. Pour se protéger des attaques FTP, il faut définir des permissions de lecture seules dans les fichiers appropriés, que ce soit sous NT ou UN*X.

TCP_wrappers

A moins que le service FTP soit prioritaire et de haute importance, faites le tourner depuis tcpd.
Pour cela, rajoutez la ligne suivante dans /etc/inetd.conf :

ftp	stream	tcp	nowait	root	/usr/sbin/tcpd	in.proftpd

PAM

Sous Linux : installez le fichier suivant dans /etc/pam.d/ftp

#%PAM-1.0
auth       required	/lib/security/pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed
auth       required	/lib/security/pam_pwdb.so shadow nullok
# This is disabled because anonymous logins will fail otherwise,
# unless you give the 'ftp' user a valid shell, or /bin/false and add
# /bin/false to /etc/shells.
auth       required	/lib/security/pam_shells.so
account    required	/lib/security/pam_pwdb.so
session    required	/lib/security/pam_pwdb.so
Verifiez que l'utilisateur ftp ait comme shell /bin/false et que /bin/false soit déclaré dans le fichier /etc/shells

TFTP

Ce protocole est une version "relax" de FTP. Normalement les utilisateurs peuvent transférer tout fichiers (même les fichiers systèmes comme le Registres de Windows NT ou /etc/password, son équivalent UN*X) sans mot de passe. À moins d'en avoir absolument besoin, nous recommandons fortement de supprimer le fichier tftpd. Si votre réseau a un service TFTPD, désactivez-le (/etc/inetd.conf).

Administration

Script de démarrage

#!/bin/sh
#
# Startup script for ProFTPd
#
# chkconfig: 345 85 15
# description:	ProFTPD is an enhanced FTP server with a focus toward
#		simplicity, security, and ease of configuration.
#		It features a very Apache-like configuration syntax,
#		and a highly customizable server infrastructure,
#		including support for multiple 'virtual' FTP servers,
#		anonymous FTP, and permission-based directory visibility.
# processname:	proftpd
# config:	/etc/proftp.conf
#
# By: Osman Elliyasa <osman@Cable.EU.org>
# $Id: proftpd.init.d,v 1.1 1999/10/23 04:07:58 macgyver Exp $

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration
. /etc/sysconfig/network

# Check that networking is up
[ ${NETWORKING} = "no" ] && exit 0

[ -f /etc/proftpd.conf ] || exit 0

FTPSHUT=%{prefix}/sbin/ftpshut

# See how we were called.
case "$1" in
  start)
	echo -n "Starting proftpd: "
	if [ -x ~ftp-master/bin/advert.sh ]; then
		echo -n "Adverts "
		su - ftp-master -c "bin/advert.sh fifo"
	fi
	$0 resume
	daemon proftpd
	echo
	touch /var/lock/subsys/proftpd
	;;
  stop)
	echo -n "Shutting down proftpd: "
	if [ -x ~ftp-master/bin/advert.sh ]; then
		echo -n "Adverts "
		su - ftp-master -c "bin/advert.sh kfifo"
	fi
	$0 suspend
	killproc proftpd
	echo
	rm -f /var/lock/subsys/proftpd
	;;
  status)
	status proftpd
	;;
  restart)
	$0 stop
	$0 start
	;;
  reload)
	echo -n "Re-reading /etc/proftpd.conf config file: "
	killproc proftpd -HUP
	echo
	;;
  suspend)
	if [ -f $FTPSHUT ]; then
		if [ $# -gt 1 ]; then
			shift
			echo -n "Suspending with '$*' "
			$FTPSHUT $*
		else
			echo -n "Suspending NOW "
			$FTPSHUT now "Maintanance in progress"
		fi
	else
		echo -n "No way to suspend "
	fi
	echo
	;;
  resume)
	if [ -f /etc/shutmsg ]; then
		echo -n "Allowing sessions again "
		rm -f /etc/shutmsg
	else
		echo -n "Was not suspended "
	fi
	echo
	;;
  *)
	echo -n "Usage: $0 {start|stop|status|restart|reload|resume"
	if [ "$FTPSHUT" = "" ]; then
		echo "}"
	else
		echo "|suspend}"
		echo "suspend accepts additional arguments which are passed to ftpshut(8)"
	fi
	exit 1
esac

if [ $# -gt 1 ]; then
	shift
	$0 $*
fi

exit 0

Rotation de journal

/var/log/xferlog {
    missingok
    notifempty
    postrotate
	/usr/bin/killall -HUP in.proftpd
    endscript
    compress
}

Analyseur de journal

Documentation

Pages de manuel


Christophe Merlet
redfox@redfoxcenter.org
©Tous droits réservés
21 juin 2001