FTP is short for File Transfer Protocol. This guide covers how to configure FTP Server in Linux. FTP is used to transfer file from one computer to another over any type of network. An FTP server can receive traffic over FTP protocol and allow transfer of files.
We are using VSFTP for our FTP server in Linux. VSFTP stands for Very Secure FTP server. We have used Fedora based system for purpose of installation. Similar method will apply to Red hat / SUSE.
To learn how connect and Download and Upload files from FTP server in Linux, refer below command.
Configuration of FTP Server in Linux
Installing FTP sever – vsftp
Installing FTP server will require to use command dnf
dnf -y install vsftpd
Once installed you will have start vsftp manually
Start vsftp – ftp in Linux and configuring start-up at boot
systemctl start vsftpd
In order to ensure vsftpd start automatically at time of restart use command
systemctl enable vsftpd
Configuring Firewall to enable vsftpd
If you are using firewall, then you must configure it to allow ftp server communication.
Allow FTP service on firewall using below command
firewall-cmd --add-service=ftp –permanent
Next allow FTP communication port to communicate through firewall. Assuming you have configured Passive FTP server with range 31000-31010.
firewall-cmd --add-port=31000-31010/tcp –permanent
Finally reload your new rules
Allow anonymous user login to vsftpd server
Allowing anonymous user in vsftpd server involves multiple steps – creation of folder for sharing ftp contents and configuring anonymous access.
Create folder for sharing files on ftp
First create folder for sharing files using ftp
mkdir -p /ftp/shared/
Now set permissions of folder so as
sudo chown nobody:nogroup /ftp/shared/
After this step copy or create any file in this folder for later testing.
Allowing anonymous in vsftpd configuration file
Open vsftpd configuration file, go to below configuration line and set it to yes.
Also disable local user login
Folder created earlier in marked as anonymous root folder changing below configuration
restart your ftp services
sudo systemctl restart vsftpd
Now you can login anonymously in your ftp in Linux Server.
Allow user-based access to vsftpd server
Here we will enable ftp server to enable user access based on user list given in /etc/vsftpd.userlist .
First enable user list, for this following configuration need to be changed from YES to NO
Second enable user list, for this make below change in configuration
Final configuration should look like
Now if you want user to be in chroot jail to their default home directory, i.e they will not be able to access files above this directory in hierarchy. To change this make following changes in configuration file
Also, you can give write access to user by changing
Save the file and restart vsftpd services
Restart vsftpd services
systemctl restart vsftpd