FTP (File Transfer Protocol) is a traditional and widely used standard tool for transferring files between a server and clients over a network, especially where no authentication is necessary it permits anonymous users to connect to a server. We must understand that FTP is unsecure by default, because it transmits user credentials and data without encryption.
Today, am going to describe the steps to install, configure and secure a FTP server (VSFTPD stands for (Very Secure FTP Daemon) in VPS
Step 1 : Installing FTP server
1. Just run the following comment in the terminal => vsftpd is a software name of FTP
# yum install vsftpd -y
2. After installing the software we should start and enable the service, By default the service will be disabled at first, So we need to start it manually for the first time and enable it to start automatically from the next system boot as well
# systemctl start vsftpd # systemctl enable vsftpd
3. Next, in order to allow access to FTP services from external systems, we have to open port 21 in the firewall using below commands:
# firewall-cmd --zone=public --permanent --add-port=21/tcp # firewall-cmd --zone=public --permanent --add-service=ftp # firewall-cmd --reload
Step 2: Configuring FTP Server
4. Now we will move over to perform a few configurations to setup and secure our FTP server, let us start by making a backup of the original config file /etc/vsftpd/vsftpd.conf file.
# cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bk
Next, open the config file and make the changes from YES to NO
5. Now configure FTP to allow/deny FTP access to users based on the user list file /etc/vsftpd/user_list
Users listed in the above file is not permited to login to FTP
6. Now add these two following options to restrict FTP users to their Home directories
Now save the file.
7. Restart the service
# systemctl restart vsftpd
Now we will test FTP server by creating a FTP user
# useradd -m test # passwd test@123
Option -m will Create the user’s home directory if it does not exist.
Now you can access the ftp using the below command :
# ftp 192.168.43.105
Connected to 192.168.43.105 (192.168.43.105). 220 (vsFTPd 3.0.2) Name (192.168.43.105:root): harry 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp>
That’s all now you can use the ftp commands to access the files in the user’s home directory
Note : By default the FTP command will not work in your vps, So you can install ftp by following the below command
# yum install ftp -y