Introduction
FTP stands for File Transfer Protocol. It is similar to HTTP (HyperText Transfer Protocol), in that it specifies a language for transferring data over a network. FTP is unencrypted by default, so by itself, it is not a good choice for secure transmission of data.
Step 1: Update System Packages
sudo apt update
Step 2: Install vsftpd Server on Ubuntu
A common open-source FTP utility used in Ubuntu is vsftpd. It is recommended for its ease of use.
1. To install vsftpd, enter the command:
sudo apt install vsftpd
2. To launch the service and enable it at startup, run the commands:
sudo systemctl start vsftpd
sudo systemctl enable vsftpd
Step 3: Backup Configuration Files
Before making any changes, make sure to back up your configuration files.
1. Create a backup copy of the default configuration file by entering the following:
sudo cp /etc/vsftpd.conf /etc/vsftpd.conf_default
Step 4: Create FTP User
Create a new FTP user with the following commands:
sudo useradd -m testuser
sudo passwd testuser
Step 5: Configure Firewall to Allow FTP Traffic
If you are using UFW that comes standard with Ubuntu, it will block FTP traffic by default. Enter the following commands to open Ports 20 and 21 for FTP traffic:
sudo ufw allow 20/tcp
sudo ufw allow 21/tcp
Configuring Ubuntu vsftpd Server
Change Default Directory
By default, the FTP server uses the /srv/ftp directory as the default directory. You can change this by creating a new directory and changing the FTP user home directory.
To change the FTP home directory, enter the following:
sudo mkdir /srv/ftp/new_location
sudo usermod -d /srv/ftp/new_location ftp
Restart the vsftpd service to apply the changes:
sudo systemctl restart vsftpd.service
Now, you can put any files you want to share via FTP into the /srv/ftp folder (if you left it as the default), or the /srv/ftp/new_location/ directory (if you changed it).
Hope this blog will be helpful for you.