Configurazione di proftpd con mod_tls o mod_sftp

5 agosto 2011 by Roberto Puzzanghera 0 commenti

Ecco come ho installato mod_tls (ftpes) e mod_sftp in proftpd. I miei tentativi di farli convivere in due demoni separati sono tutti falliti, giacchè ho registrato errori nel trasferimento che sono spariti solo quando ho provato a caricare mod_tls o mod_sftp a turno.

Questi i miei test sulla velocità (per la verità un po' frettolosi). ftpes sembra un pochino più veloce in modalità upload:

ftpes
upload: circa 22.4 K/s
download: più di 800 K/s

sftp
upload circa 18.2 K/s
download: più di 800 K/s

Le mie opzioni di configurazione:

./configure \
        --prefix=/usr/local \
        --without-pam --disable-auth-pam \
        --enable-openssl \
        --with-modules=mod_ratio:mod_readme:mod_sftp:mod_tls

file ftpes.conf

# common stuff goes here
Include /usr/local/etc/proftpd/proftpd.conf

<IfModule mod_tls.c>
TLSEngine on
PassivePorts 49152 65535
#MasqueradeAddress 012.345.678.901 # se il server e' dietro un firewall
TLSLog /var/log/proftpd/tls.log
TLSProtocol SSLv23
# Require protection on the control channel, but reject protection of the data channel
TLSRequired ctrl+!data
TLSRSACertificateFile /usr/local/etc/ssl/certs/proftpd.pem
TLSRSACertificateKeyFile /usr/local/etc/ssl/certs/proftpd.pem
TLSVerifyClient off
TLSRenegotiate none
</IfModule>

file sftp.conf

# common stuff
Include /usr/local/etc/proftpd/proftpd.conf

<IfModule mod_sftp.c>
SFTPEngine on
SFTPLog /var/log/proftpd/sftp.log
Port 22
SFTPHostKey /etc/ssh/ssh_host_rsa_key
SFTPHostKey /etc/ssh/ssh_host_dsa_key
SFTPCompression delayed
MaxLoginAttempts 6
</IfModule>

Infine avviare il demone richiamando il file di configurazione desiderato:

/usr/local/sbin/proftpd -c /usr/local/etc/proftpd/ftpes.conf # se si vuole ftpes
/usr/local/sbin/proftpd -c /usr/local/etc/proftpd/sftp.conf  # se si preferisce sftp

Non avviarli mai insieme.

file proftpd.conf

ServerType standalone
UseReverseDNS off
DeferWelcome off

Port 21
Umask 022
MaxInstances 30

User ftp
Group ftp

SystemLog /var/log/proftpd/proftpd.log
TransferLog /var/log/proftpd/xferlog

<Global>

<Directory /*>
AllowOverwrite on
</Directory>

</Global>

<VirtualHost 123.456.789.123>

ServerName "ProFTPD"
DefaultRoot ~/www
DefaultServer on

</VirtualHost>

Startup script

#!/bin/sh
#
# /etc/rc.d/rc.proftpd
#

start() {
        /usr/local/sbin/proftpd -c /usr/local/etc/proftpd/ftpes.conf
#-n -d 20 for backup
#        /usr/local/sbin/proftpd -c /usr/local/etc/proftpd/sftp.conf
        echo "Server started."
}

stop() {
        /bin/killall proftpd
        echo "Server stopped."
}

restart() {
        stop
sleep 3
        start
#/bin/killall -HUP proftpd
        echo "Server restarted."
}

case "$1" in
'start')
  start
  ;;
'stop')
  stop
  ;;
'restart')
  restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac

 

Aggiungi un commento