x32x01
  • by x32x01 ||
FTP (File Transfer Protocol) is a network protocol used to transfer files between two machines. Setting up an FTP server on Raspberry Pi is simple but make sure you do not transfer sensitive data as this protocol does not use encryption.

In this tutorial, you will learn to set up an FTP server on your Raspberry Pi.
How to Setup FTP Server on Your Raspberry Pi
Prerequisites
  • Raspberry Pi OS installed on your device
  • Memory card
  • Network connection
  • Account with root privileges
Raspberry Pi FTP Server Setup Guide
Setting up the FTP server requires:
1. A server utility.
2. Changes in some configuration files.
3. Setting up the server directory.
4. Modifying permissions for the server user.

Note: When you want to make sure your file transfers are secured, it is better to use SFTP (Secure File Transfer Protocol) over SSH.

Follow these steps to set up an FTP server on your Raspberry Pi:

Step 1: Update System Packages
Before installing the FTP utility, update the system package repositories and run an upgrade:
Code:
sudo apt update
Code:
sudo apt full-upgrade
Confirm with Y and wait for the upgrade to complete.

Step 2: Install FTP Server
There are several utilities available for setting up an FTP server on Raspberry Pi. In this tutorial, we will use the open-source vsftpd utility.
The vsftpd utility is lightweight, secure, and easy to use.
Install vsftpd on the Raspberry Pi by running:
Code:
sudo apt install vsftpd
Wait for the installation to complete.

Step 3: Edit Configuration File
Before connecting to the FTP server, modify the settings in the vsftpd configuration file using a text editor, for example, nano.
1. Run the following command:
Code:
sudo nano /etc/vsftpd.conf
edit-the-vsftpd-configuration-file.png
2. Find (CTRL + W) and uncomment the following lines by removing the hash (#) sign:
Code:
write_enable=YES
Code:
local_umask=022
Code:
chroot_local_user=YES
3. Find the following line:
Code:
anonymous_enable=YES
Change it to:
Code:
anonymous_enable=NO
4. Add the following lines at the end of the config file:
Code:
user_sub_token=$USER
Code:
local_root=/home/$USER/FTP
These settings lock the server users to the FTP folder within the home directory.

5. Press CTRL + X and confirm with Y to save the settings and exit.

Step 4: Create FTP Directory
Create an FTP directory to use for transferring files. A subdirectory is needed since the root directory cannot have write permissions.
Use the following syntax:
Code:
mkdir -p /home/[user]/FTP/[subdirectory_name]
Replace [user] with the relevant user. Replace [subdirectory_name] with a name of your choice. The default user on Raspberry Pi OS is ‘pi.’

For example:
make-a-directory-on-the-ftp-server.png
The -p argument instructs mkdir to create the entire path tree, both FTP and files directories.

Step 5: Modify Permissions
After adding the directory, remove the write permission from the FTP directory to prevent other users from adding files to it.
Use the following syntax:
Code:
chmod a-w /home/[user]/FTP
Replace the [user] syntax with the appropriate username.

For example:
remove-write-permissions-from-ftp-users.png

Step 6: Restart Vsftpd Daemon
To apply the changes, restart the vsftpd daemon by running:
Code:
sudo service vsftpd restart
Now the FTP server is set up and running on the Raspberry Pi.

FTP Server Test
Test the server using a remote machine and FileZilla, a popular FTP client that supports all platforms.
Follow these steps:
1. Install FileZilla on a remote machine.
For example, on Ubuntu, run the command:
Code:
sudo apt install filezilla
Confirm with Y and wait for the installation to complete.

2. Obtain the Pi’s IP address by running the following command in the Raspberry Pi terminal:
Code:
ifconfig
obtain-ip-address-using-ifconfig.png
In this case, we used the private IP address to connect locally.
3. Open FileZilla on another machine and enter the Pi’s IP address, username, and password for the user you want to connect to. The default username is ‘pi,’ and the default password is ‘raspberry.’ Port number is 21.

Click Quickconnect to establish a connection.
connect-to-ftp-server-using-filezilla-e1617614481523.png
If the connection is successful, a message stating Connection established appears in the log.
establish-connection-to-ftp-server-using-filezilla-e1617614422961.png
4. On the remote machine, drag and drop some files from a source to the destination directory in FileZilla to make sure the connection is working.
transfer-file-to-ftp-server-using-filezilla-e1617614378774.png
If everything works, FileZilla states that the file transfer was successful. Our example is for a local transfer, but the procedure is the same in other cases.

Conclusion
Now you know how to set up an FTP server on your Raspberry Pi. The solution is simple and works well when transferring files between two computers. You can use this setup as private cloud storage and keep the costs low.
 

Similar Threads

x32x01
Replies
0
Views
36
x32x01
x32x01
x32x01
Replies
0
Views
28
x32x01
x32x01
x32x01
Replies
0
Views
111
x32x01
x32x01
x32x01
Replies
0
Views
132
x32x01
x32x01
x32x01
  • x32x01
Replies
0
Views
208
x32x01
x32x01
TAGs: Tags
file transfer protocol ftp ftp server raspberry pi setup ftp server

Register & Login Faster

Forgot your password?

Latest Resources

Forum Statistics

Threads
517
Messages
518
Members
44
Latest Member
Zodiac
Back
Top