Table of Content#
- Prerequisites
- Installing ProFTPD
- Generating SSL/TLS Certificates
- Configuring ProFTPD for TLS/SSL
- Testing the Secure Connection
- Troubleshooting Common Issues
- Conclusion
- References
1. Prerequisites#
- A server running RHEL/CentOS 7.
- Root or sudo access to the server.
- Basic knowledge of Linux commands and text editors (e.g.,
viornano).
2. Installing ProFTPD#
First, update the system packages:
sudo yum update -yThen, install the EPEL repository (required for ProFTPD packages on RHEL/CentOS 7):
sudo yum install epel-release -yNext, install ProFTPD:
sudo yum install proftpd -yAfter installation, install the TLS module:
sudo yum install proftpd-mod_tls -yAfter installation, start the ProFTPD service and enable it to start on boot:
sudo systemctl start proftpd
sudo systemctl enable proftpd3. Generating SSL/TLS Certificates#
Using OpenSSL (Self - Signed Certificate)#
- Create a directory to store the certificates (if not already present):
sudo mkdir /etc/proftpd/ssl- Generate a private key:
sudo openssl genrsa -out /etc/proftpd/ssl/proftpd.key 2048- Generate a self - signed certificate. You will be prompted to enter various details (e.g., country name, common name). For a self - signed certificate, the common name should match the domain or IP address of your server.
sudo openssl req -new -x509 -key /etc/proftpd/ssl/proftpd.key -out /etc/proftpd/ssl/proftpd.crt -days 365Using Let's Encrypt (for a more trusted certificate)#
- Install the
certbotutility (if not already installed):
sudo yum install certbot -y- If your server has a domain name associated with it, you can use the following command to obtain a certificate. For example, if your domain is
example.com:
sudo certbot certonly --standalone -d example.comThe certificates will be stored in /etc/letsencrypt/live/example.com/ (replace example.com with your actual domain). You can copy the fullchain.pem (certificate) and privkey.pem (private key) to the ProFTPD SSL directory:
sudo cp /etc/letsencrypt/live/example.com/fullchain.pem /etc/proftpd/ssl/proftpd.crt
sudo cp /etc/letsencrypt/live/example.com/privkey.pem /etc/proftpd/ssl/proftpd.key4. Configuring ProFTPD for TLS/SSL#
- Open the ProFTPD configuration file. The main configuration file is usually
/etc/proftpd/proftpd.conf.
sudo vi /etc/proftpd/proftpd.conf- Add the following lines to enable TLS/SSL. If you are using a self - signed certificate:
TLSEngine on
TLSLog /var/log/proftpd/tls.log
TLSProtocol TLSv1.2
TLSRSACertificateFile /etc/proftpd/ssl/proftpd.crt
TLSRSACertificateKeyFile /etc/proftpd/ssl/proftpd.key
TLSVerifyClient off
TLSRequired on
If you are using a Let's Encrypt certificate (and assuming the paths are correct as in the previous step):
TLSEngine on
TLSLog /var/log/proftpd/tls.log
TLSProtocol TLSv1.2
TLSRSACertificateFile /etc/proftpd/ssl/proftpd.crt
TLSRSACertificateKeyFile /etc/proftpd/ssl/proftpd.key
TLSVerifyClient off
TLSRequired on
- Save and close the file. Then, restart the ProFTPD service:
sudo systemctl restart proftpd5. Testing the Secure Connection#
- On a client machine, you can use an FTP client that supports TLS/SSL (e.g., FileZilla).
- In the client, enter the server address, username, and password. For the protocol, select "FTPES - FTP over explicit TLS/SSL".
- Try to connect. If everything is configured correctly, you should see a secure connection (usually indicated by a lock icon or a message about a secure connection).
6. Troubleshooting Common Issues#
Certificate Errors#
- Error: "Certificate is not trusted":
- If using a self - signed certificate, the client may need to be configured to trust the certificate. In some FTP clients, you can import the self - signed certificate.
- If using Let's Encrypt, make sure the certificate has not expired. Check the expiration date using
openssl x509 -in /etc/proftpd/ssl/proftpd.crt -noout -dates.
- Error: "Certificate hostname mismatch":
- Ensure that the common name in the certificate matches the server's domain or IP address. You may need to regenerate the certificate.
Connection Issues#
- Error: "Connection refused":
- Check the firewall settings. Make sure port 21 (FTP control port) and the passive ports (if using passive mode) are open. For example, if using
firewalld:
- Check the firewall settings. Make sure port 21 (FTP control port) and the passive ports (if using passive mode) are open. For example, if using
sudo firewall-cmd --add-service=ftp --permanent
sudo firewall-cmd --reload- Error: "Login failed":
- Double - check the username and password. Also, ensure that the user has the appropriate permissions to access the FTP server.
7. Conclusion#
By following the steps in this blog, you have learned how to secure ProFTPD connections using the TLS/SSL protocol on RHEL/CentOS 7. This helps protect your data during file transfer, making your FTP server more secure. Remember to regularly update your certificates (especially if using Let's Encrypt) and monitor the server for any security - related issues.