Come rendere sicuro un server FTP

In tutte le distribuzioni Linux è presente un server FTP. In questo tutorial vi spiegherò come renderlo sicuro utilizzando il protocollo TLS (Transport Layer Security).

Per prima cosa bisogna installare OpenSSL e vsftpd:

sudo apt-get -y install vsftpd openssl

Dopodiché create un certificato SSL da mettere nella directory /etc/ssl/private:

mkdir -p /etc/ssl/private
chmod 700 /etc/ssl/private
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout /etc/ssl/private/vsftpd.pem -out
/etc/ssl/private/vsftpd.pem

Inserite i dati richiesti. Alla fine dovrete attivare TLS in vsftpd inserendo alla fine del file /etc/vsftpd.conf queste righe:

    # Turn on SSL
    ssl_enable=YES

    # Allow anonymous users to use secured SSL connections
    allow_anon_ssl=YES

    # All non-anonymous logins are forced to use a secure SSL connection in order to
    # send and receive data on data connections.
    force_local_data_ssl=YES

    # All non-anonymous logins are forced to use a secure SSL connection in order to send the password.
    force_local_logins_ssl=YES

    # Permit TLS v1 protocol connections. TLS v1 connections are preferred
    ssl_tlsv1=YES

    # Permit SSL v2 protocol connections. TLS v1 connections are preferred
    ssl_sslv2=NO

    # permit SSL v3 protocol connections. TLS v1 connections are preferred
    ssl_sslv3=NO

    # Disable SSL session reuse (required by WinSCP)
    require_ssl_reuse=NO

    # Select which SSL ciphers vsftpd will allow for encrypted SSL connections (required by FileZilla)
    ssl_ciphers=HIGH

    # This option specifies the location of the RSA certificate to use for SSL
    # encrypted connections.
    rsa_cert_file=/etc/ssl/private/vsftpd.pem

Impostate “force_local_logins_ssl” e “force_local_data_ssl” su TRUE per accettare accessi unicamente con connessione TLS.
Come ultima cosa dovrete riavviare vsftpd:

service vsftpd restart

Lascia un commento

Il tuo indirizzo email non sarà pubblicato.