Why Choose vsftpd?
When you need to allow users to upload and download files from your Linux server, the File Transfer Protocol (FTP) remains a popular choice. vsftpd (Very Secure FTP Daemon) is the default FTP server in Ubuntu and CentOS. As the name implies, it was written with a heavy emphasis on security, offering robust features like chroot jailing (locking users to their home directories) and support for FTPS (FTP over SSL/TLS) to encrypt the otherwise plain-text credentials.
Step 1: Install the vsftpd Package
Open your terminal, update your package cache, and install the vsftpd package:
sudo apt update
sudo apt install vsftpd -y
The service will automatically start. You can check its status using sudo systemctl status vsftpd.
Step 2: Backup and Edit the Configuration File
Before modifying the server’s behavior, always backup the original configuration file:
sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.backup
Now, open the configuration file in your text editor:
sudo nano /etc/vsftpd.conf
Step 3: Configure Basic Security and Access
Scroll through the vsftpd.conf file and ensure the following directives are configured exactly as shown to enable secure local user access:
anonymous_enable=NO(Disables anonymous, password-less logins)local_enable=YES(Allows standard Linux users in /etc/passwd to log in)write_enable=YES(Allows users to upload or modify files)
Step 4: Lock Users to Their Home Directories (Chroot Jail)
By default, when an FTP user logs in, they can navigate up the directory tree and browse critical system files (like /etc). To prevent this, you must “jail” them to their home directory.
Uncomment or add the following line in your configuration file:
chroot_local_user=YES
Crucial Security Fix: vsftpd enforces a strict security rule that the root of a chroot jail must not be writable by the user. If you plan to let users upload files directly into their home directory, you must add this specific bypass directive to the bottom of the file:
allow_writeable_chroot=YES
Step 5: Restart and Test the FTP Server
Save and close the configuration file. Restart the service to apply the changes:
sudo systemctl restart vsftpd
Open an FTP client like FileZilla on your personal computer. Enter the IP address of your Ubuntu server, along with the username and password of a standard Linux user account. You should successfully connect and be placed directly into that user’s home folder, completely unable to navigate anywhere else on the server filesystem.