Ubuntu FTP Server File Sharing Setup Guide (Using vsftpd)
vsftpd (Very Secure FTP Daemon) is the most widely used FTP server software on Ubuntu due to its security and stability. Below is a step-by-step guide to setting up an FTP server for file sharing, including key configurations and troubleshooting tips.
Update your system’s package list and install vsftpd using the following commands:
sudo apt update
sudo apt install vsftpd
Edit the vsftpd configuration file to enable essential features and enhance security:
sudo nano /etc/vsftpd.conf
Modify or add the following key parameters (uncomment lines by removing the # if necessary):
anonymous_enable=NO
local_enable=YES
write_enable=YES
chroot_local_user=YES
allow_writeable_chroot=YES # Required if chroot is enabled (lets users write to their home directory).
pasv_enable=YES
pasv_min_port=50000
pasv_max_port=50100
Save changes (Ctrl+O, Enter) and exit (Ctrl+X).
Apply configuration changes by restarting the service:
sudo systemctl restart vsftpd
Enable automatic startup on boot:
sudo systemctl enable vsftpd
Create a dedicated FTP user (replace ftpuser with your preferred username):
sudo adduser ftpuser
Set a strong password and complete the prompts.
Set the user’s home directory permissions to ensure proper access:
sudo chown ftpuser:ftpuser /home/ftpuser
sudo chmod 755 /home/ftpuser
If you’re using UFW (Uncomplicated Firewall), allow FTP ports to permit incoming connections:
sudo ufw allow 21/tcp # Standard FTP control port
sudo ufw allow 50000:50100/tcp # Passive mode data ports (adjust to your config)
sudo ufw reload
For iptables, use these commands (replace with your passive port range):
sudo iptables -A INPUT -p tcp --dport 21 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 50000:50100 -j ACCEPT
sudo service iptables save
Use an FTP client (e.g., FileZilla) or command line to verify connectivity:
ftp localhost
Enter the FTP user’s credentials. If successful, you’ll see the server’s welcome message and can use commands like ls (list files) or put (upload).local_enable=YES is set in /etc/vsftpd.conf. Check the PAM service name in the config file matches vsftpd.vsftpd.conf.755 permissions and is owned by the user (e.g., chown ftpuser:ftpuser /home/ftpuser).This setup provides a secure and functional FTP server for file sharing on Ubuntu. For enhanced security, consider using SFTP (SSH File Transfer Protocol) instead, which encrypts all traffic by default.