Raspberry Pi FTP

In this guide we’re going to take a look at 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.

If you like to see how things are done visually then please check out the video I have put together below. If you like what you see, then please make sure you subscribe so you stay up to date.

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)

How to set it up

Setting up FTP is really easy and don’t actually 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 you can skip ahead to the “How to connect” section.
 

  1. On the Raspberry Pi open up 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 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, 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 just 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 un-comment(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
  1. Once you are done press ctrl+x and then y to save and exit.
  2. 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 sub folder 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
  1. Now restart the service by entering the following command
sudo service vsftpd restart
  1. You should now be able to connect over plain FTP (Port 21).

How to connect

You can connect to the server by using a FTP client, I am going to recommend using FileZilla however there plenty more out there. Any kind of FTP client should be able to connect to the server fine.

  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 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.

Share This!
The Raspberry Pi Crash Course

The Raspberry Pi Crash Course

Enter your email address below to get the

Raspberry Pi crash course delivered straight to your inbox

Please check your inbox for a confirmation email!