Raspberry Pi FTP Server Setup: Secure File Transfers with SFTP, Automation & Real-World Use Cases
Mar 4th,2026

A Raspberry Pi FTP Server can transform this small, affordable computer from a learning tool into a powerful solution capable of handling real infrastructure tasks.One of the most practical uses is turning a Raspberry Pi into a file server. By using FTP or SFTP, you can transfer files between computers, automate backups, or share data across a local network or even remotely.
This article explains what FTP means in the context of Raspberry Pi, compares available file-transfer protocols, and walks through both the recommended SFTP setup and the alternative FTP option. The focus is on simplicity, security, and real-world usability.
What Is FTP on Raspberry Pi
In practice, FTP on Raspberry Pi uses this standard network protocol to move files between a client and the Pi acting as a server.When running FTP on a Raspberry Pi, the Pi acts as the server, listening for incoming connections and allowing authenticated users to upload or download files.

Traditionally, FTP has been used for website management, internal file sharing, and system maintenance. However, classic FTP sends data and passwords in plain text, which introduces security risks if used incorrectly or over the internet.
Why Use Raspberry Pi as a File Server
Using a Raspberry Pi File Server setup offers several advantages:
Low cost and low power consumption
•Always-on availability
•Compact and silent operation
•Ideal for learning networking and Linux fundamentals
Despite its small size, a Raspberry Pi can reliably serve files for home labs, small offices, IoT projects, and development environments.
Common Use Cases
•Centralized file storage on a local network
•Transferring logs or data from IoT devices
•Automated backups from PCs or servers
•Sharing files between Linux, Windows, and macOS
•Lightweight alternative to a NAS for simple Raspberry Pi network storage needs
Mini Project: Build an Automated Backup & Data Drop Server with Raspberry Pi (Real-World Use Case)
A Raspberry Pi SFTP Server is often set up not just to transfer files manually, but to create a lightweight, always-on automation hub.
This section demonstrates a practical scenario: turning your Raspberry Pi into a central data receiver and backup node for other devices on your network.
Scenario: Collecting Data from Multiple Devices Automatically
Imagine you have:
A desktop PC that needs nightly backups
An ESP32 / IoT device uploading sensor logs
A laptop that syncs project files when connected to Wi-Fi
A home lab generating test results you want stored centrally
Instead of running a heavy NAS system, your Raspberry Pi can act as a low-power secure drop server using SFTP for secure file transfer on Raspberry Pi.
This is where
Raspberry Pi shines:
Always on
Uses <10W power
Silent operation
Reliable for scheduled transfers
Step 1 — Create a Dedicated Data Directory
We create a structured storage area to keep uploads organized for efficient Raspberry Pi data transfer workflows.
sudo mkdir -p /srv/data/{pc_backup,iot_uploads,lab_results}
sudo chown -R ftp_sunfounder:ftp_sunfounder /srv/data
This keeps automated uploads separate from the system filesystem.
Example structure:
/srv/data/
├── pc_backup/
├── iot_uploads/
└── lab_results/
Step 2 — Restrict the SFTP User to This Directory (Secure Drop Zone)
Edit the SSH configuration:
sudo nano /etc/ssh/sshd_config
Add:
Match User ftp_sunfounder
ChrootDirectory /srv/data
ForceCommand internal-sftp
X11Forwarding no
AllowTCPForwarding no
Restart SSH:
sudo systemctl restart ssh
Now this account can only upload/download files, not access the OS.
This turns the Pi into a controlled file appliance rather than a general Linux login.
Step 3 — Example: Automate Backup from a Linux / macOS Machine
Create a simple scheduled sync using
rsync over SSH (secure + efficient).
rsync -avz ~/Documents/ ftp_sunfounder@raspberrypi:/pc_backup/
To automate nightly:
crontab -e
Add:
0 2 * * * rsync -avz ~/Documents/
ftp_sunfounder@raspberrypi:/pc_backup/
Now the Raspberry Pi becomes an automatic backup target every night at 2 AM.
Step 4 — Example: Upload Files from Windows Using WinSCP Script
Windows machines can automate uploads using WinSCP scripting:
open sftp://ftp_sunfounder:password@192.168.1.50
put C:\Logs\* /lab_results/
exit
Schedule this in Task Scheduler → Fully automated data push.
Step 5 — Example: IoT Device Uploading Sensor Logs
Many embedded devices support SCP/SFTP uploads.
Example (Linux-based edge device):
scp sensor.csv ftp_sunfounder@192.168.1.50:/iot_uploads/
Now the Raspberry Pi becomes a central ingestion point for IoT data, enabling remote file transfer with Raspberry Pi without cloud infrastructure.
Step 6 — Add Automatic File Organization (Optional but Powerful)
You can let the Pi sort incoming files using a simple cron job.
Create a script:
nano /usr/local/bin/organize_uploads.sh
#!/bin/bash
find /srv/data/iot_uploads -type f -mtime +7 -exec gzip {} \;
Make executable:
chmod +x /usr/local/bin/organize_uploads.sh
Schedule it:
30 3 * * * /usr/local/bin/organize_uploads.sh
Now older uploads are automatically compressed to save space.
Why This Approach Is Better Than Running a Full NAS
| Raspberry Pi SFTP Server | Full NAS Stack |
|---|---|
| Uses <10W power | Often 25–60W |
| Simple to maintain | Requires web UI + services |
| No database required | Heavier system load |
| Fast to deploy | Longer setup time |
| Perfect for automation | Designed for interactive storage |
For developers, labs, and IoT environments, a Raspberry Pi SFTP setup is often the smarter lightweight solution.
When This Design Makes the Most Sense
This Raspberry Pi FTP/SFTP model is ideal when you need:
✔ A secure automation endpoint
✔ A staging server for data collection
✔ A low-cost backup target
✔ A bridge between embedded devices and PCs
✔ A learning platform for Linux + networking
It is not meant to replace enterprise NAS, but it is extremely effective for edge infrastructure.
Key Takeaway
Running FTP/SFTP on Raspberry Pi is not just about file transfer —
it allows the Pi to act as a tiny always-on infrastructure node that quietly handles backups, synchronization, and device data collection.
This is one of the most practical real-world roles for a Raspberry Pi in home labs and engineering environments.
FTP vs SFTP vs SMB: Which One to Use
Differences Explained
•FTP: Classic file transfer protocol, simple but insecure by default.
•SFTP: File transfer over SSH. Encrypted, secure, and widely supported.
•SMB: Windows-style file sharing, best for mapped network drives.
| Feature | FTP | SFTP | SMB |
|---|---|---|---|
| Default Encryption | ❌ No | ✅ Yes (SSH) | ✅ Yes (modern versions) |
| Port Used | 21 + passive ports | 22 | 445 |
| Setup Complexity | Medium (passive ports required) | Low | Medium |
| Firewall Friendly | ❌ Often problematic | ✅ Yes | ⚠️ Depends on network |
| Internet Safe by Default | ❌ No | ✅ Yes | ❌ Not recommended |
| Best For | Legacy systems | Secure file transfers | Network drive sharing |
| Shell Access Required | No | Uses SSH | No |
| Ease of Remote Access | Complicated | Simple | Complex |
Security Comparison
FTP does not encrypt credentials or data unless extended with TLS (FTPS),), as documented in the official File Transfer Protocol specification.SMB is secure on trusted networks but not ideal for internet exposure. SFTP encrypts everything by default and runs over SSH, making it much safer.
Recommendation: Why SFTP Is Preferred
For most secure file transfer on Raspberry Pi setups, SFTP is the best choice.It requires no extra software, is secure by default, and works well across platforms.
Requirements
•Raspberry Pi (any model with network support)
•USB storage or SSD for larger files
•Raspberry Pi OS Lite or Desktop
Preparing the Raspberry Pi
Update the System
Keeping the system up to date ensures security patches and stability — especially when combined with proper firewall rules explained in our guide on Raspberry Pi firewall configuration.
https://www.sunfounder.com/blogs/news/raspberry-pi-update-essential-steps-for-a-secure-and-optimized-system
IMPORTANT: Find the Raspberry Pi IP address: hostname -I
Enable SSH
SSH is required for SFTP and remote management— as also highlighted in SunFounder’s Raspberry Pi home automation security guide.
sudo raspi-config
Enable SSH under Interface Options.

Choosing the Protocol
When to Use SFTP
•Secure file transfers
•Remote access over the internet
•Automation scripts
•Professional or production environments
When to Use FTP
•Legacy systems
•Closed, trusted networks
•Devices that do not support SFTP
SFTP Path (Recommended)
Option A: SFTP Using OpenSSH
√Why SFTP Is Already Available
Raspberry Pi OS includes OpenSSH by default. No additional packages are required to enable SFTP functionality.
√No Extra Software Needed
As soon as SSH is enabled, SFTP works automatically.
Setting Up SFTP on Raspberry Pi
1.Verify SSH Service
sudo systemctl status ssh

2.Create Users
There are two main reasons:
Security: If someone gains access to the SFTP credentials, they will only have access to that specific user account — not the entire system. This limits potential damage and protects important system files.
Controlled File Access: By assigning the user to a dedicated directory, you can restrict them to a single folder. This is called a chroot jail. It prevents the user from browsing the full Linux filesystem.
Create a dedicated user for file transfers:
sudo adduser ftp_sunfounder
3.Configure Permissions
Create a folder for file access:
sudo mkdir /home/sftp_sunfounder/files
sudo chown ftp_sunfounder: ftp_sunfounder /home/sftp_sunfounder /files
sudo chmod 755 /home/sftp_sunfounder/files

4.Test Local Connection
From the Pi itself:
sftp ftp_sunfounder@localhost

Test Remote Connection
From another machine with WinSCP:


FTP Path (Alternative)
Option B: FTP Using vsftpd
When FTP Still Makes Sense
FTP can still be useful in controlled environments or when compatibility with older devices is required, as noted in this overview of FTP use cases.
Installing and Configuring vsftpd
1.Install vsftpd
sudo apt install vsftpd
2.Basic Configuration
Edit the configuration file:
sudo nano /etc/vsftpd.conf

listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
allow_writeable_chroot=YES
Explanation:
•anonymous_enable=NO: Disables anonymous access
•local_enable=YES: Allows system users to log in
•write_enable=YES: Allows file uploads
•chroot_local_user=YES: Restricts users to their home directory
•allow_writeable_chroot=YES: Required for writable directories
Creating Dedicated FTP Users
1.Create users
sudo adduser ftp_sunfounder
By default, with chroot_local_user=YES, the user will be restricted to: /home/ftp_sunfounder/files
1.Configure Permissions
sudo chown ftp_sunfounder:ftp_sunfounder /home/ftp_sunfounder/files
sudo chmod 755 /home/ftp_sunfounder/files
2.Restart FTP service: /etc/init.d/vsftpd restart
Test Remote Connection
From another machine, example with File Explorer on Windows 11

Passive Mode Configuration (Critical for Real-World Use)
This is the part many tutorials skip — and the reason FTP often fails.
FTP uses two channels:
1.Control connection (port 21)
2.Data connection (random high ports)
If passive mode is not configured properly, FTP connections may:
•Connect successfully but fail to list files
•Freeze during transfer
•Work locally but fail behind a router
Enable Passive Mode
Add the following to /etc/vsftpd.conf:
pasv_enable=YES
pasv_min_port=40000
pasv_max_port=40100
This defines a fixed range of passive ports (40000–40100).
If your Raspberry Pi is behind a router and accessed externally, also add:
pasv_address=YOUR_PUBLIC_IP
Replace with your public IP address or domain name.
Why Passive Ports Matter
Without defining a fixed passive port range:
•The server chooses random high ports
•Routers and firewalls block those ports
•The data channel fails
•Clients show timeout or directory listing errors
By defining a fixed range, you can open only those specific ports in your firewall and router.
Firewall Configuration (UFW Example)
If you use UFW (recommended), allow FTP control and passive ports.
Enable UFW if not active:
sudo ufw enable
Allow FTP control port:
sudo ufw allow 21/tcp
Allow passive port range:
sudo ufw allow 40000:40100/tcp
Check status:
sudo ufw status
Without opening passive ports, FTP will partially work but fail during transfers.
Router Port Forwarding (If Remote Access Is Needed)
If accessing the FTP server from the internet:
Forward these ports on your router:
•TCP 21 → Raspberry Pi IP
•TCP 40000–40100 → Raspberry Pi IP
Important: FTP exposed to the internet without TLS encryption is not secure.
Optional – Enable FTPS (Encrypted FTP)
To add encryption (FTPS), generate a self-signed certificate:
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/ssl/private/vsftpd.key \
-out /etc/ssl/private/vsftpd.pem
Then add to vsftpd.conf:
ssl_enable=YES
rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.key
force_local_data_ssl=YES
force_local_logins_ssl=YES
Restart the service.
This encrypts credentials and data, making FTP significantly — though still more complex than SFTP, as explained in the FTPS protocol overview.
Important Security Warning
Classic FTP:
•Sends passwords in plain text
•Is unsafe over public networks
•Should not be exposed to the internet without TLS
Even with FTPS enabled, SFTP remains simpler, cleaner, and more secure because:
•It uses a single port (22)
•It avoids passive mode complexity
•It encrypts everything by default
It integrates directly with SSH
Common Real-World FTP Failures
×Connection Established but Directory Listing Fails
Cause:
Passive ports blocked.
Fix:
Open passive port range in firewall and router.
×Connection Refused
Cause:
vsftpd not running or firewall blocking port 21.
Fix:
sudo systemctl status vsftpd
×Timeout During Transfer
Cause:
Firewall blocking passive data ports.
Conclusion
Setting up a Raspberry Pi FTP Server is more than a simple file-transfer exercise—it is a practical way to turn the device into a lightweight, always-on infrastructure tool. While traditional FTP can still serve legacy or tightly controlled environments, modern deployments should favor SFTP for its built-in encryption, simpler networking requirements, and seamless integration with SSH. By combining secure file access with automation tools like rsync, scheduled tasks, and structured directories, a Raspberry Pi can act as a reliable hub for backups, IoT data collection, and cross-platform file sharing without the complexity or power demands of a full NAS system. This approach highlights one of the Raspberry Pi’s greatest strengths: delivering flexible, low-cost solutions for real-world computing tasks — similar to building server-based systems like a self-hosted Raspberry Pi email server.
