Raspberry Pi

How to Setup FTP on Raspberry Pi

The FTP (File Transfer Protocol) is a method by which we can upload and transfer the files from the sender to the receiver using the internet connection as it allows you to send the large file of size in the gigabytes with a full security. The FTP server can also be used to transfer files to the Raspberry Pi but for this we have to set up the FTP settings on the Raspberry Pi which are explained in detail in this write-up.

How to setup the FTP on the Raspberry Pi

It is always recommended that before installing any new package, update the repository to get the latest version of the packages and then also use the upgrade command, so that previous outdated packages can be update to the latest versions:

$ sudo apt update && sudo apt full-upgrade -y

Now it’s time to install the “vsftpd” package which comes by default in the repository of the Raspberry Pi:

$ sudo apt install vsftpd

When the installation command of vsftpd executed successfully, we will check the status of the installed vsftpd service using the systemctl command:

$ sudo systemctl status vsftpd

In the above output, it can be seen that the vsftpd service is running, now we will enable it with the help of the command:

$ sudo systemctl enable vsftpd

To add the user in the vsftpd, run the command:

$ sudo adduser ftpuser

When the command is executed, it will ask you to set a password for the new user and then it will ask the personal information about the new user created:

Type “y” to confirm the above information and close the terminal. To confirm the creation of the new user we will run the command:

$ echo “Hammad” | sudo tee -a /etc/vsftpd.userlist

The “Hammad” user has successfully been created, now we will make the directory with the name of ftp_dir in the /home/ftpuser/ with the command:

$ sudo mkdir -p /home/ftpuser/ftp_dir

In the above command “-p” option is used to tell the mkdir to create the entire path tree and next step is to change the permission status of the ftp_dir using the chmod command to make it accessible:

$ sudo chmod -R 750 /home/ftpuser/ftp_dir

After changing the permissions, we will open the configuration file of vsftpd using the nano text editor:

$ sudo nano /etc/vsftpd.conf

Now in the list open, make sure the following lines have been there and uncomment them by removing the “#”:




Then type these lines in the file:




After making sure all the above lines are in the configuration file of vsftpd and uncommented, save the changes in the file and exit the nano editor. Finally we will create a dummy 2048-bit private key and a self created certificate with the validity of 10 years by using the command:

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

This certificate is saved in the same directory of ftp_dir, now we will restart the vsftpd service to save and apply the new changes made:

$ sudo systemctl restart vsftpd

Confirm the status of the vsftpd service by using the command:

$ sudo systemctl status vsftpd

Allow the ports 20 and 21 using the ufw command:

$ sudo ufw allow 20/tcp && sudo ufw allow 21/tcp

Reload the ufw to apply the rules added:

$ sudo ufw reload

Now we will open the Filezilla from another machine and type the “Host”, username and password and connect to it:

Once the connection is established successfully, we can move the files from the laptop to the host using the Filezilla:

Now in the terminal of the Raspberry Pi we will list down the contents of the ftp-dir to confirm the transfer of the file:

$ sudo ls /home/ftpuser/ftp_dir

The image in the ftp_dir has confirmed that the file has been successfully transferred after the setup of FTP on the Raspberry Pi.


FTP allows the transfer of the files of any size with the security over the internet. In this write-up, the FTP server has been set up on the Raspberry Pi by installing the FTP on the Raspberry Pi and then we have transferred a file from the laptop to the Raspberry Pi using the Filezilla service.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.