Sunday, October 14, 2012

vsftpd + TLS/SSL - encrypt ftp sessions


FTP is a very insecure protocol because all passwords and all data are transferred in clear text. By using TLS, the whole communication can be encrypted, thus making FTP much more secure.

  1. Install openssl
  2. mkdir -p /etc/ssl/private && chmod 700 /etc/ssl/private
  3. openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem
  4. edit /etc/vsftpd.conf
  5. [...]
    # 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
    [...]
      5. /etc/init.d/vsftpd restart

No comments:

Post a Comment