Ubuntu vsftpd Security Strategies
First, update the package index and install vsftpd—the default FTP server for Ubuntu—using:
sudo apt update && sudo apt install vsftpd -y
This ensures you have the latest stable version with security patches.
Edit the configuration file to enforce core security settings:
anonymous_enable=NO
/etc/shadow) to log in.local_enable=YES
write_enable=YES
allow_writeable_chroot to avoid permission errors when uploading files.chroot_local_user=YES
allow_writeable_chroot=YES
pasv_enable=YES
pasv_min_port=50000
pasv_max_port=50100
These settings form the foundation of vsftpd hardening.
Encrypt data in transit to prevent eavesdropping. Generate a self-signed certificate (or use a trusted CA-signed one) and configure vsftpd to enforce TLS:
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem
/etc/vsftpd.conf, enable SSL and disable insecure protocols (SSLv2/SSLv3).ssl_enable=YES
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.pem
Clients must use FTPS (FTP over SSL/TLS) to connect.
Limit access to trusted users via whitelisting:
/etc/vsftpd.user_list (one per line).echo "ftpuser1" | sudo tee -a /etc/vsftpd.user_list
echo "ftpuser2" | sudo tee -a /etc/vsftpd.user_list
/etc/vsftpd.conf, enable the list and deny all non-listed users.userlist_enable=YES
userlist_file=/etc/vsftpd.user_list
userlist_deny=NO
For stricter control, place users in a chroot list (/etc/vsftpd.chroot_list) to ensure they cannot access other directories.
Use UFW to restrict access to FTP ports:
sudo ufw allow 21/tcp
pasv_min_port/pasv_max_port).sudo ufw allow 50000:50100/tcp
sudo ufw enable
Verify rules with sudo ufw status verbose.
Enable detailed logs to detect suspicious activity (e.g., failed logins, large file transfers):
xferlog_enable=YES
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES
syslog_enable=YES
Regularly review logs using:
sudo tail -f /var/log/vsftpd.log
Logs help identify and respond to potential attacks (e.g., brute-force attempts).
sudo apt update && sudo apt upgrade -y
vsftpd; verify with ps aux | grep vsftpd).By implementing these strategies, you can significantly enhance the security of your Ubuntu vsftpd server and protect against common FTP vulnerabilities.