Set up a Raspberry Pi as an FTP server – vsftpd, ProFTPD and SFTP

Raspberry Pi FTP Server Setup – SFTP, vsftpd and ProFTPD

The Raspberry Pi is perfect as a permanently running file server thanks to its low power consumption. In this guide I’ll show you three proven methods to set up an FTP server on your Raspberry Pi – from a simple SFTP solution that needs no installation, to a full vsftpd or ProFTPD server with TLS encryption.

In short

For most people, SFTP is the best choice: it runs over SSH, it’s encrypted and there’s nothing to install.

  • vsftpd if a device or app only speaks classic FTP. Turn on TLS (FTPS) before you open the server to the internet.
  • ProFTPD if you need several users with group and directory rules.
  • Keep plain, unencrypted FTP on your home network and never expose it to the internet.

SFTP, FTP or FTPS – Which Method Is Right for You?

Before we start, here’s a quick overview of the three protocols:

Protocol Port Encryption Installation Required Recommended For
SFTP 22 Yes (SSH) No Home network + internet
FTPS 21 + TLS Yes (TLS) vsftpd / ProFTPD When FTP clients are required
FTP 21 No vsftpd / ProFTPD Home network only

If you’d rather use the Pi’s storage like a network drive in File Explorer or Finder, Samba is more convenient than FTP. Raspberry Pi File Server with Samba covers the setup with a USB drive, and Raspberry Pi 5 as a NAS the version with an NVMe SSD. If you want syncing, calendars and access from a phone app, your own cloud with Nextcloud is the better fit.

Requirements

  • A Raspberry Pi running Raspberry Pi OS on your home network, via Ethernet or Wi-Fi. All three methods work on the Pi 3, 4, 5 and Zero 2 W.
  • Access to the Pi’s command line, either directly or over SSH
  • A second computer with an FTP client such as FileZilla or WinSCP
  • For access from outside your home: a FritzBox or another router that supports port forwarding

Storage: SD Card or External Drive?

Without extra hardware, your files end up on the SD card. That’s fine for occasional transfers. If you regularly store larger amounts of data, add an external drive: you get more space, and the SD card doesn’t have to absorb all those writes.

Links marked with * are affiliate links, which makes them advertising. If you buy through one, I earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases. Learn more

On the Pi 4 and Pi 5, plug USB drives into one of the blue USB 3 ports. If a hard drive without its own power supply keeps dropping out, the Pi isn’t delivering enough power. Our guide on USB hard drives without external power explains how to fix that.

To format the drive and mount it permanently, follow Set Up a USB Hard Drive on Raspberry Pi, which also shows you how to check write permissions. Then point your FTP server at the drive. Do this once you’ve set up the method you chose further down:

  • SFTP: In your FTP client, open the folder where the drive is mounted, for example /mnt/usbdisk.
  • vsftpd: Create a folder on the drive that belongs to your user and add it at the end of /etc/vsftpd.conf, for example local_root=/mnt/usbdisk/ftp. After sudo systemctl restart vsftpd, you land straight in that folder when you log in and can’t go above it. The setting applies to all local users, including pi.
  • ProFTPD: When you create ftpuser, replace /var/www/upload with a folder on the drive in all three commands.

If you’d like to boot the whole system from the SSD, see Boot Raspberry Pi from SSD.

Method 1: SFTP – Ready Immediately, No Installation

SFTP (SSH File Transfer Protocol) runs over SSH and is automatically active on every Raspberry Pi as soon as SSH is enabled. Nothing to install.

Enable SSH

If SSH isn’t active yet, enable it via raspi-config:

sudo raspi-config

Select Interface Options → SSH → Enable.

Username and hostname: The examples use the username pi and the hostname raspberrypi, so pi@raspberrypi.local. Raspberry Pi OS hasn’t had a default pi account since 2022, so use the username and hostname you set up yourself, usually in Raspberry Pi Imager. In the same way, /home/pi becomes /home/<your-name>.

SFTP with FileZilla (Windows/macOS/Linux)

  1. Download and start FileZilla
  2. Enter the following in the Quickconnect bar at the top:
    • Host: sftp://IP-address-of-Pi
    • Username: pi (or your username)
    • Password: your password
    • Port: 22
  3. Click Quickconnect

SFTP with WinSCP (Windows)

WinSCP is a particularly comfortable SFTP alternative for Windows with a Windows Explorer-style interface. Select protocol SFTP, enter the IP address and credentials – that’s it.

SFTP via Command Line (Linux/macOS)

# Upload a file to the Pi
scp myfile.txt pi@raspberrypi.local:/home/pi/

# Download a file from the Pi
scp pi@raspberrypi.local:/home/pi/myfile.txt ./

# Start an interactive SFTP session
sftp pi@raspberrypi.local

Method 2: vsftpd Server (Recommended for Classic FTP)

vsftpd (Very Secure FTP Daemon) is the lightest and fastest FTP server for the Raspberry Pi. It’s easy to configure and supports TLS encryption.

Install vsftpd

sudo apt update && sudo apt upgrade -y
sudo apt install vsftpd -y

Configure vsftpd

Open the configuration file:

sudo nano /etc/vsftpd.conf

Some of these settings are already in the file. Use CTRL+W to find them and adjust them:

  • anonymous_enable=NO and local_enable=YES are already set this way by default, so leave them as they are.
  • Remove the leading # in front of write_enable=YES and chroot_local_user=YES. chroot_local_user appears twice as a comment in the file; changing one of them is enough.

Afterwards, these lines look like this:

anonymous_enable=NO
local_enable=YES
write_enable=YES
chroot_local_user=YES

The remaining settings aren’t in the file at all. Add them at the end:

# Allow writing inside the chroot directory
allow_writeable_chroot=YES

# Passive mode for NAT/router compatibility
pasv_enable=YES
pasv_min_port=40000
pasv_max_port=40100

Save with CTRL+X, Y, Enter.

Start and Enable vsftpd

sudo systemctl restart vsftpd
sudo systemctl enable vsftpd
sudo systemctl status vsftpd

Test the FTP Connection

Connect from another device on the network using FileZilla or WinSCP:

  • Protocol: FTP
  • Host: IP address of the Raspberry Pi
  • Username: pi (or another local user)
  • Password: your password
  • Port: 21

Enable TLS Encryption for vsftpd (FTPS)

For a secure connection over the internet, FTPS – FTP with TLS encryption – is recommended.

First, create a self-signed certificate:

sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
  -keyout /etc/ssl/private/vsftpd.pem \
  -out /etc/ssl/private/vsftpd.pem

You can skip all fields with Enter or enter any values you like. Now enable TLS in the vsftpd configuration:

sudo nano /etc/vsftpd.conf

Add the following block at the end of the file:

# Enable TLS/FTPS
ssl_enable=YES
rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.pem
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=NO
ssl_sslv2=NO
ssl_sslv3=NO
require_ssl_reuse=NO

Restart vsftpd:

sudo systemctl restart vsftpd

In FileZilla, go to File → Site Manager → New site, choose FTP as the protocol and set Encryption to “Require explicit FTP over TLS”.

Method 3: ProFTPD Server (More Configuration Options)

ProFTPD offers more configuration options than vsftpd and is suited for more complex setups with different user groups and directory restrictions.

Install ProFTPD

sudo apt update && sudo apt upgrade -y
sudo apt install proftpd-core -y

The installation runs without any prompts, and ProFTPD starts as a standalone service.

Adjust the Configuration

Change the ServerName:

sudo nano /etc/proftpd/proftpd.conf
ServerName "Raspberry Pi FTP"

User Configuration with Group Restriction

Create a separate configuration file that survives updates:

sudo nano /etc/proftpd/conf.d/custom.conf
# No valid login shell required
<global>
    RequireValidShell off
</global>

# Restrict users to their home directory
DefaultRoot ~ ftpuser

# Only ftpuser group can log in
<limit LOGIN>
    DenyGroup !ftpuser
</limit>

Create an FTP User

# Dedicated FTP user without login shell
sudo adduser ftpuser --shell /bin/false --home /var/www/upload

# Create upload directory and set permissions
sudo mkdir -p /var/www/upload
sudo chown ftpuser:ftpuser /var/www/upload

adduser asks you to set a password for ftpuser. That’s the password you’ll use to log in with FileZilla later. Just press Enter for the other questions, such as name and phone number.

Start and Enable ProFTPD

sudo systemctl restart proftpd
sudo systemctl enable proftpd
sudo systemctl status proftpd

Enable TLS Encryption for ProFTPD (FTPS)

The same rule applies to ProFTPD: only use it over the internet with TLS. The TLS module comes in a separate package:

sudo apt install proftpd-mod-crypto -y

The module is commented out in the modules file by default. Open it and remove the hash in front of LoadModule mod_tls.c:

sudo nano /etc/proftpd/modules.conf

The line should then look like this:

LoadModule mod_tls.c

Next, create a self-signed certificate. As with vsftpd, you can skip the prompts with Enter:

sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
  -keyout /etc/ssl/private/proftpd.key \
  -out /etc/ssl/certs/proftpd.crt

The TLS settings go into their own file in the conf.d folder, so that, like custom.conf, they survive package updates:

sudo nano /etc/proftpd/conf.d/tls.conf
<IfModule mod_tls.c>
    TLSEngine on
    TLSLog /var/log/proftpd/tls.log
    TLSProtocol TLSv1.2 TLSv1.3
    TLSRSACertificateFile /etc/ssl/certs/proftpd.crt
    TLSRSACertificateKeyFile /etc/ssl/private/proftpd.key
    TLSRequired on
</IfModule>

PassivePorts 40000 40100

TLSRequired on rejects every unencrypted login. PassivePorts sets the port range for the data connection, which you will also forward on your router later. Restart ProFTPD:

sudo systemctl restart proftpd

In FileZilla, connect the same way as with vsftpd, with encryption set to “Require explicit FTP over TLS”. Accept the self-signed certificate once when you first connect.

Open FTP Port in FritzBox (Internet Access)

If you want to access the FTP server from outside your home network, you need to forward the FTP port in your FritzBox. Important: Only use FTPS or SFTP – never plain unencrypted FTP over the internet!

  1. Open the FritzBox interface: http://fritz.box. As of FRITZ!OS 8.50, AVM recommends http://fritzbox.local instead, but fritz.box still works on your home network.
  2. Internet → Permit Access → Port Sharing tab → Add Device for Sharing
  3. Select the Raspberry Pi
  4. Forward TCP port 21 (for FTPS) or port 22 (for SFTP)
  5. For passive mode (vsftpd and ProFTPD), also forward TCP ports 40000–40100

Troubleshooting

vsftpd: “500 OOPS: vsftpd: refusing to run with writable root inside chroot()”

vsftpd refuses the login if the chroot directory is writable and allow_writeable_chroot=YES is missing. If you see this error, first check that the line is at the end of vsftpd.conf as described above. If you’d rather do without that option, make the home directory read-only instead and create a subfolder (uploads/) for writing:

sudo chmod a-w /home/pi
sudo mkdir /home/pi/uploads
sudo chown pi:pi /home/pi/uploads

Replace pi with your own username here.

Connection Refused – Check Firewall

Check if ufw is active on the Raspberry Pi:

sudo ufw status

If you get command not found, ufw isn’t installed and isn’t blocking anything. The cause lies elsewhere, for example a service that isn’t running (sudo systemctl status vsftpd or proftpd) or the port forwarding on your router.

If it shows Status: active, open the FTP ports:

# For vsftpd and ProFTPD
sudo ufw allow 21/tcp
sudo ufw allow 40000:40100/tcp

# For SFTP
sudo ufw allow 22/tcp
Which FTP server is better – vsftpd or ProFTPD?

For simple use cases, vsftpd is faster and easier to configure. ProFTPD offers more flexibility for user management and directory restrictions.

Can I use FTP and SFTP at the same time on the Raspberry Pi?

Yes. SFTP runs over SSH (port 22) and is always active once SSH is enabled. vsftpd or ProFTPD run in parallel on port 21 and do not interfere with SFTP.

How do I find the IP address of my Raspberry Pi?

The easiest way is the command hostname -I directly on the Pi, or via the FritzBox interface.

Does vsftpd work with Raspberry Pi 5?

Yes, all three methods (SFTP, vsftpd, ProFTPD) work with Raspberry Pi OS on all Pi models (Pi 3, 4, 5, Zero 2 W).

Similar Posts