How To Secure A FTP Server Using SSLTLS For Secure File Transfer in CentOS 7
How To Secure A FTP Server Using SSLTLS For Secure File Transfer in CentOS 7
By its original design, FTP (File Transfer Protocol) is not secure, meaning it doesn’t
encrypt data being transmitted between two machines, along with user’s credentials. This
poses a massive threat to data as well as server security.
In this tutorial, we will explain how to manually enable data encryption services in a FTP
server in CentOS/RHEL 7 and Fedora; we will go through various steps of securing
VSFTPD (Very Secure FTP Daemon) services using SSL/TLS certificates.
Prerequisites:
Before we start, note that all the commands in this tutorial will be run as root, otherwise,
use the sudo command to gain root privileges if you are not controlling the server using the
root account.
# mkdir /etc/ssl/private
2. Then run the command below to create the certificate and key for vsftpd in a single file,
here is the explanation of each flag used.
1/9
The above command will ask you to answer the questions below, remember to use values
that apply to your scenario.
4. Now, open the VSFTPD config file and specify the SSL details in it:
# vi /etc/vsftpd/vsftpd.conf
Look for the option ssl_enable and set its value to YES to activate the use of SSL, in
addition, since TSL is more secure than SSL, we will restrict VSFTPD to employ TLS
instead, using the ssl_tlsv1_2 option:
ssl_enable=YES
ssl_tlsv1_2=YES
ssl_sslv2=NO
ssl_sslv3=NO
5. Then, add the lines below to define the location of the SSL certificate and key file:
rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.pem
6. Next, we have to prevent anonymous users from using SSL, then force all non-
anonymous logins to use a secure SSL connection for data transfer and to send the
password during login:
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
2/9
7. In addition, we can add the options below to boost up FTP server security. When option
require_ssl_reuse is set to YES , then, all SSL data connections are required to exhibit
SSL session reuse; proving that they know the same master secret as the control channel.
require_ssl_reuse=NO
Again, we need to select which SSL ciphers VSFTPD will permit for encrypted SSL
connections with the ssl_ciphers option. This can greatly limit efforts of attackers who
try to force a particular cipher which they probably discovered vulnerabilities in:
ssl_ciphers=HIGH
8. Now, set the port range (min and max port) of passive ports.
pasv_min_port=40000
pasv_max_port=50000
9. Optionally, allow SSL debugging, meaning openSSL connection diagnostics are recorded
to the VSFTPD log file with the debug_ssl option:
debug_ssl=YES
Save all the changes and close the file. Then let’s restart VSFTPD service:
# ftp 192.168.56.10
Connected to 192.168.56.10 (192.168.56.10).
220 Welcome to TecMint.com FTP service.
Name (192.168.56.10:root) : ravi
530 Non-anonymous sessions must use encryption.
Login failed.
421 Service not available, remote server has closed connection
ftp>
3/9
Verify FTP SSL Secure Connection
From the screen shot above, we can see that there is an error informing us that VSFTPD
can only allow user to login from clients that support encryption services.
The command line does not offer encryption services thus producing the error. So, to
securely connect to the server, we need a FTP client that supports SSL/TLS connections
such as FileZilla.
12. When the installation completes (or else if you already have it installed), open it and go
to File=>Sites Manager or (press Ctrl+S ) to get the Site Manager interface below.
4/9
Add New FTP Site in Filezilla
13. Next, set the host/site name, add the IP address, define the protocol to use, encryption
and logon type as in the screen shot below (use values that apply to your scenario):
Host: 192.168.56.10
Protocol: FTP – File Transfer Protocol
Encryption: Require explicit FTP over #recommended
Logon Type: Ask for password #recommended
User: username
5/9
Add FTP Server Details in Filezilla
14. Then click on Connect to enter the password again, and then verify the certificate
being used for the SSL/TLS connection and click OK once more to connect to the FTP
server:
6/9
Verify FTP SSL Certificate
At this stage, we should have logged successfully into the FTP server over a TLS connection,
check the connection status section for more information from the interface below.
7/9
Connected to FTP Server Over TLS/SSL
15. Last but not least, try transferring files from the local machine to the FTP sever in the
files folder, take a look at the lower end of the FileZilla interface to view reports
concerning file transfers.
8/9
Transfer Files Securely Using FTP
That’s all! Always keep in mind that FTP is not secure by default, unless we configure it to
use SSL/TLS connections as we showed you in this tutorial. Do share your thoughts about
this tutorial/topic via the feedback form below.
9/9