An ftp server on a Raspberry Pi enables file transfers between devices on a local network or over the internet using the File Transfer Protocol. It runs on Linux, uses standard ports (21 for control, 20 for data), and supports authentication via username and password.
Setting up an ftp server on a Raspberry Pi requires installing a daemon like vsftpd (Very Secure FTP Daemon), configuring access permissions, and managing firewall rules. The system runs on a headless or desktop version of Raspberry Pi OS, typically accessed via SSH or terminal.
Once configured, any device on the same network-Windows PC, Mac, Android tablet, or another Raspberry Pi-can connect using an FTP client such as FileZilla, WinSCP, or the built-in command-line tools. Files can be uploaded, downloaded, or deleted through a graphical interface or command prompt.
The ftp server operates on a client-server model. When a client connects, the server establishes a control channel on port 21 to exchange commands like LIST, RETR (retrieve), STOR (store), and QUIT. Data transfers happen over a separate data channel, either active mode (client opens port) or passive mode (server opens port).
For security, most setups disable anonymous access and require a valid user account. The server checks credentials against the system's user database or a custom list. File ownership and permissions are enforced based on Unix-style access controls.
Network address translation (NAT) and firewalls can block connections unless port forwarding is set up correctly. For remote access, a static IP or changing DNS service ensures consistent connectivity.
Key elements include:
To install vsftpd:
sudo apt update
sudo apt install vsftpd -y
After installation, edit the config file:
sudo nano /etc/vsftpd.conf
Set these lines:
anonymous_enable=NO
local_enable=YES
write_enable=YES
chroot_local_user=YES
allow_writeable_chroot=YES
Save and exit. Restart the service:
sudo systemctl restart vsftpd
Test with:
ftp localhost
Enter the username and password. If prompted, log in as the user created earlier.
There are two main modes for FTP connections:
| Mode | Use Case | Port Range | Security Note |
|---|---|---|---|
| Active | Simple LAN transfers | Client-side ephemeral ports | Blocked by many firewalls |
| Passive (PASV) | Remote access behind NAT | Server-defined range (e.g., 50000-51000) | Recommended for public access |
Passive mode is preferred for home networks and cloud setups because it avoids issues with stateful firewalls. Configure the passive port range in /etc/vsftpd.conf:
pasv_enable=YES
pasv_min_port=50000
pasv_max_port=51000
Use cases include:
A common mistake is assuming FTP is secure. It transmits passwords and data in plain text. Always use SFTP (SSH File Transfer Protocol) or FTPS (FTP over TLS) for sensitive data. vsftpd supports SSL/TLS, but setup requires a certificate.
Many users think FTP works out of the box. It doesn't. The default configuration disables local users and anonymous access. If you can't connect, check:
sudo systemctl status vsftpd.sudo ufw allow 21.ls -ld /home/username.Another confusion: FTP is not the same as SFTP. SFTP uses SSH port 22 and encrypts all traffic. It's faster and safer. To enable SFTP, ensure OpenSSH is installed:
sudo apt install openssh-server -y
Then connect via:
sftp [email protected]
I once set up an ftp server on a Raspberry Pi Zero W to transfer audio recordings from a field research station. The Pi ran on a battery pack and connected via Wi-Fi. I used passive mode and port 50000-50500. After setting up UFW and assigning a static IP, I could stream files to a laptop over a 3G hotspot. The transfer speed was ~1.2 MB/s, sufficient for 10-minute audio clips.
Never run an FTP server exposed to the internet without encryption. Use a reverse proxy like Nginx with Let's Encrypt certificates for HTTPS tunneling. Or better yet, switch to SFTP or rsync over SSH.
Limit user access to specific directories. Create a dedicated group for file-sharing users and assign read/write permissions only to needed folders.
Monitor logs at /var/log/vsftpd.log to detect failed attempts. Set up fail2ban to block repeated login tries:
sudo apt install fail2ban -y
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
Add this block:
[vsftpd]
enabled = true
port = 21
filter = vsftpd
logpath = /var/log/vsftpd.log
maxretry = 3
Run sudo systemctl restart fail2ban to apply changes.
Always test connectivity from multiple devices. Use netstat -tuln | grep :21 to confirm the server is listening. If nothing appears, the service may have failed to start.
Finally, remember: an ftp server raspberry pi is not a backup solution. Use rsync, BorgBackup, or cloud sync tools for long-term data protection.
With proper configuration, an ftp server on a Raspberry Pi becomes a reliable, low-cost tool for file sharing in labs, homes, and small offices.