In this guide, we are going to take a look at setting up FTP on the Raspberry Pi. Setting up FTP will allow for easy transferring of files to and from your Pi over a network.
For those who don’t know, FTP stands for File Transfer Protocol and is simply a method for transferring files between two devices over a network
There is also an additional method that you can be used instead. This method is called SFTP, it stands for Secure File Transfer Protocol. This version of the protocol works over SSH.
The biggest difference between these two methods comes down to their security. SFTP is considered to be much more secure thanks to its use of encryption for the transfer of data.
We should also note that it is possible to use both FTP and SFTP at the same time as they operate on difference ports. By default FTP operates on port
21, while SFTP operates on port
Using FTP is a great way to move files on and off of the Raspberry Pi without needing any fancy setups or physical access to the device itself.
Setting up SFTP is a very straightforward process as it is part of the SSH standard.
Using FTP requires a few more steps but is also fairly simple to set up, mainly requiring us to install a separate server software such as vsftpd.
An extra bonus you should also check out our guide on how to 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 SD card.
So, let’s get started with learning how to set up FTP and SFTP on the Raspberry Pi.
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 Wi-Fi
In this FTP server tutorial we are using Raspberry Pi OS.
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 for a beginner)
Be sure to check out our video below for a visual guide on setting up FTP on your Raspberry Pi.
Alternatively we have a full written guide just below this video.
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.
Adblock removing the video? Support us by subscribing to our ad-free service.
Setting up your Raspberry Pi for SFTP
Setting up your Raspberry Pi to be able to use SFTP is a very straightforward process and requires no additional software to be installed.
All we need to do is make sure that SSH is enabled by using the Raspi-config tool.
If you have already got SSH enabled, then you can skip ahead to the “How to Connect” section further down in this tutorial.
1. On the Raspberry Pi open up the terminal.
You can find this in the task bar at the top of the screen by default.
Alternatively you can press CTRL + ALT + T to open the terminal.
2. Within the terminal you will need to enter the following command.
This command will launch the raspi-config tool that we can use to enable SFTP on your Raspberry Pi.
3. Within this tool you need to go to the “
5 Interfacing Options” option.
You can navigate through the menu by using the ARROW keys to move up and down, then the ENTER key to select an option.
4. On the next screen find and select the “
P2 SSH” option.
This option is what will allow us to enable the SSH service on our Raspberry Pi.
5. To actually enable SSH on your device, you need to select the
Enabling SSH will give us access to the SFTP functionality of the protocol.
6. At this point you have now successfully enabled SSH on your Raspberry Pi.
You can quit out of this tool now by pressing the ESC key.
7. You can now proceed down to our “
How to Connect to the FTP Server” section of this tutorial.
This section will walk you through connecting to your Raspberry Pi over the SFTP protocol.
You will be able to connect to the Raspberry Pi over SFTP by using port
Setting up an FTP Server on the Raspberry Pi
In this section we are going to be walking you through the process of getting plain FTP working on your device.
To make all of this work we will be making use of a piece of software called vsftpd.
We chose to use vsftpd as it is regarded as one of the most secure and fastest FTP servers that you can run on the Raspberry Pi.
1. Before we proceed let us ensure that our Raspberry Pi OS is running the latest available packages.
To update all packages on the device you will need to run the following two commands on the terminal.
sudo apt update sudo apt full-upgrade
Updating all packages ensures that we shouldn’t run in to any weird issues when installing vsftpd on to our Raspberry Pi.
2. Once the update process has completed we can now install the software we require.
Install vsftpd to your Raspberry Pi by using the command below.
sudo apt install vsftpd
3. Before we can connect to our new Raspberry Pi FTP server we need to modify some settings.
Let us begin modifying the vsftpd configuration file by using the nano text editor with the following command.
sudo nano /etc/vsftpd.conf
4. Within this file you will need to add or uncomment (Remove the #) the following settings.
If you want to find options faster you can make use of the CTRL + W shortcut to search the file.
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
Using these options we set it so that the user logging in is locked in to there directory.
In our case we are using “
local_root” option so that the user will be locked to their home directory within a folder called “
5. Once you are done press CTRL + X and then Yto save and exit.
6. 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.
<user> with the relevant user
Make sure that you replace “
<user>” with the relevant user. For example, the default user on Raspberry Pi OS is “
mkdir -p /home/<user>/FTP/files
By using the
-p argument we are telling mkdir that it needs to create the entire path tree.
So in our case it will create both our “
FTP” and “
7. With the directory added we need to modify its permissions so that we remove the write permission from the
Doing this will ensure no one can add files in to the FTP directory that they shouldn’t be.
Again make sure that you replace “
<user>” with the user that you are using.
chmod a-w /home/<user>/FTP
8. For our new settings to take effect we need to restart the vsftpd daemon on the Raspberry Pi.
We can now restart the service by using the following command.
sudo service vsftpd restart
9. With the FTP server set up and running on our Raspberry Pi you can now connect to it.
You should now be able to connect to the FTP server on your Raspberry Pi over Port
How to Connect to your Raspberry Pi’s FTP Server
You can now connect to your Raspberry Pi by using either FTP or SFTP, depending on which protocol you decided to go with.
For this tutorial we are going to by using the FileZilla FTP client as it has support for both FTP and SFTP while also working on numerous operating systems.
There are plenty more FTP clients that you can check out. Another solid alternative is WinSCP, however, that is Windows only.
Any FTP client should be able to connect to the server with little to no issues.
1. On your PC head over to the FileZilla download page and download the relevant client for your operating system.
2. Upon opening up the FileZilla software you will be able to login to your FTP server.
1 – First you need to enter in the IP address of your Raspberry Pi. (1.)
2 – Next, you need to enter the username for the user we are trying to connect with. If you are sticking with the default user this will be “
3 – After that, you will need to enter the password for that user. Again if you are using the default user you will need to use the password “
4 – The final option that needs filling out is the port. The port differs slightly depending if you are using SFTP or FTP on your Raspberry Pi.
If you are using plain FTP enter the port
21 in to the textbox. Alternatively if you are using SFTP, you will need to enter the port
3. At this point, you should enter in all the connection details for your Raspberry Pi FTP server.
Once you are happy everything is correct, connect by clicking the Quickconnect button.
4. If everything is working as it should be you should now be successfully connected over FTP or SFTP.
5. To make sure everything is working you should now test the connection by transferring a couple of files.
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
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 to make it harder for someone to try and gain access.
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 this issue, you will need to change the permission of that particular location to allow your current user 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 NAS by using protocols such as SAMBA.
I hope this guide has provided you with enough information to get your Raspberry Pi up and running with either FTP or SFTP.
If you do come across some issues or you notice a mistake then please don’t hesitate to leave a comment below.
Great tutorial, however, it grants default access to most of the upper directories. Can the tutorial be modified to limit new users to /home/guest/sftp/files for example and only /files. I personally jailed the process with chroot jail but just new users and guests should have strict limited access unless specifically granted.
perhaps chroot jail to be discussed in another great PiMyLifeUp tutorial.?
In step 3 change:
In step 5 change:
Thank you for the precious tutorial.
Thank you for pointing out those issues. We have corrected the tutorial!
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!
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.
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.
Thomas, use this command:
Daniel, 4th line must be:
sudo usermod -a -G www-data pi
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.
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.