x32x01
ADMINISTRATOR
- 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.
Prerequisites
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:
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:
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:
2. Find (CTRL + W) and uncomment the following lines by removing the hash (#) sign:
3. Find the following line:
Change it to:
4. Add the following lines at the end of the config file:
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:
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:
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:
Replace the [user] syntax with the appropriate username.
For example:
Step 6: Restart Vsftpd Daemon
To apply the changes, restart the vsftpd daemon by running:
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:
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:
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.
If the connection is successful, a message stating Connection established appears in the log.
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.
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.
In this tutorial, you will learn to set up an FTP server on your Raspberry Pi.
- Raspberry Pi OS installed on your device
- Memory card
- Network connection
- Account with root privileges
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
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
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
Code:
write_enable=YES
Code:
local_umask=022
Code:
chroot_local_user=YES
Code:
anonymous_enable=YES
Code:
anonymous_enable=NO
Code:
user_sub_token=$USER
Code:
local_root=/home/$USER/FTP
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]
For example:
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
For example:
Step 6: Restart Vsftpd Daemon
To apply the changes, restart the vsftpd daemon by running:
Code:
sudo service vsftpd restart
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
2. Obtain the Pi’s IP address by running the following command in the Raspberry Pi terminal:
Code:
ifconfig
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.
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.