How to Setup Raspberry Pi FTP

In this guide, we’re going to take a look at setting up Raspberry Pi FTP for easy transferring of files to and from your Pi over a network.

Raspberry Pi FTP

For those who don’t know, FTP stands for File Transfer Protocol, and if it has an S (SFTP) in front, then it stands for Secure File Transfer Protocol.

Using FTP is a great way to move files on and off of the Raspberry Pi Pi without needing any fancy setups or physical access to the Pi itself.

You simply need to activate a few things, and you’re good to go unless you’re after plain FTP then you need to do a little extra.

An extra bonus that you’re able to do with this tutorial is set up a mounted USB drive, so you have plenty of room for files and more. This tweak will help save you space on your main SD card.

So, let’s get started with learning how to set up FTP on the Raspberry Pi.

Equipment

You will need the following equipment to complete this tutorial on setting up an FTP server on the Raspberry Pi.

Raspberry Pi

Power Supply

Micro SD Card (8gb+ Recommended)

Ethernet Cable (Recommended) or WiFi Dongle

Raspberry Pi Case (Optional)

Video

If you like to see how to do things visually, then please check out the video I have put together below.

If you like what you see, then please make sure you subscribe or follow us on social media, so you stay up to date on our latest stuff.

Can’t see the video? Support us by disabling your adblocker.

Setting up the Raspberry Pi FTP Server

In this Raspberry Pi FTP server tutorial, we are using Raspbian, if you don’t have it installed then check out my guide on installing NOOBS Raspberry Pi. (It’s the easiest way to get Raspbian onto your SD Card)

Setting up FTP is easy and you won’t have to install any extra software. All we need to do is make sure that SSH is enabled by simply using Raspi-config. If you have already got SSH enabled, then you can skip ahead to the “How to Connect” section.

1. On the Raspberry Pi open up the terminal.

2. Enter the following command.

sudo raspi-config

3. In here, go to Advanced Options->SSH.

4. Then select enable.

5. Now you can proceed to connecting to the Pi.

Raspberry Pi SSH

External Access

If you want to access FTP outside your internal network, then please follow my guide on setting up Raspberry Pi port forwarding.

The port you want to forward for SFTP is 22, and if you’re going to enable plain FTP, then you will need to forward port 21 as well. I would suggest having a different external port then to the standard internal port.

Optional Setup

If for some reason you want to use plain FTP, you can do the following to install it. I highly recommend you stick to SFTP as it much more secure, especially if you plan on allowing internet access.

1. Using SSH or the terminal on the Pi enter the following commands.

sudo apt-get update
sudo apt-get install vsftpd

2. Now open up the config file by entering the following command.

sudo nano /etc/vsftpd.conf

3. In here add or uncomment (Remove the #) for the following settings.

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
chroot_local_user=YES
user_sub_token=$USER
local_root=/home/$USER/FTP

4. Once you are done press ctrl+x and then y to save and exit.

5. Now we need to create the FTP directory so we can transfer files. The root directory is not allowed to have write permissions so we will need a subfolder called files.

If you try to copy to FTP, it won’t work but FTP/files will. Replace <user> with the relevant user, for example

mkdir /home/<user>/FTP
mkdir /home/<user>/FTP/files
chmod a-w /home/<user>/FTP

6. Now restart the service by entering the following command.

sudo service vsftpd restart

7. You should now be able to connect over plain FTP (Port 21).

How to Connect to the FTP Server

You can connect to the server by using an FTP client, and I am going to recommend using FileZilla however there plenty more FTP clients out there. Any FTP client should be able to connect to the server without issue.

1. On your PC head over to the FileZilla download page and download the relevant client for your operating system.

2. Now enter the Raspberry Pi’s IP address, username, password and port 22.

3. Click Quickconnect.

4. It should now connect and login.

5. Test the connection by transferring a few files.

FileZilla Raspberry Pi

Troubleshooting

Permission denied: This means you’re trying copy files to or from a place where your current user doesn’t have the correct permissions. To fix you will need to change the permission of that particular location or login with a different user.

You might find that FTP isn’t enough for what you require. If you’re looking for something a little more advanced, then the network attached storage tutorial might take your fancy. Using the tutorial you can set your Pi up to act as a SAMBA server.

I hope this guide has provided you with enough information to get Raspberry Pi FTP up and running. If you do come across some issues or you notice a mistake then please don’t hesitate to leave a comment below.

8 Comments

  1. Vincenzo Frezza on

    Suggestions:

    In step 3 change:

    local_root=/home/$USER/ftp

    in

    local_root=/home/$USER/FTP

    In step 5 change:

    chmod a-w /home//ftp

    in

    chmod a-w /home//FTP

    Thank you for the precious tutorial.

    Vincenzo Frezza

    1. Gus on

      Hi Vincenzo,

      Thank you for pointing out those issues. We have corrected the tutorial!

      Cheers,
      Gus

  2. Greg on

    Since this is an FTP server, is there a way to add users (and their respective passwords) just for vsftp? I know i used fillzilla server for windows and I could add users, and also set which profile each user had access to, where the profiles were basically just groups of folders. I’m currently trying to move my ftp server from my windows machine to my pi. Thanks!

    1. mike on

      If I understand your question, you should be able to do this by adding groups in linux. Just create a group that you want to only use vsftp and give that group exclusive access.

  3. Siamak on

    Hi everyone,

    The tutorial is indeed very interesting for those who don’t have VPN servers.

    I have set-up an OpenVPN server and by using WinSCP the file transfer takes place very smoothly from any where in the world.

  4. Daniel on

    Thomas, use this command:

    sudo chgrp www-data /var/www 
    sudo chmod 777 /var/www 
    sudo chmod g+s /var/www 
    sudo usermod -a -G pi 
    sudo chown -R pi /var/www
  5. Thomas on

    how can I change the permission of the var/www/html map so I can copy files into it? I get the message that I don’t have the permission.

  6. RichardL on

    This is almost the first thing I’ve done on RPi, and it worked for plain ftp, but in points 3 and I think all the FTP/ftp folder name should be the same case.

Leave a Reply

Your email address will not be published. Required fields are marked *