Install & Setup FTP Server with VSFTPD on CentOS / RHEL
We know that FTP stands for “File Transfer Protocol,” and it’s used to transfer files online. Today I’m going to install and setup FTP on RHEL / CentOS. Let’s start:
Table of Contents
- Install VSFTPD
- Configure VSFTPD
- Secure with SSL/TLS (Optional)
- Add FTP Port to FirewalLD
- Create an FTP User
Step 1 : Install VSFTPD
By default vsftpd is available in CentOS / RHEL repository. Just run this command to install vsftpd:
sudo yum install vsftpd
After installation, start vsftpd using this command:
sudo systemctl start vsftpd
To automatically start at boot time, we need to run this:
sudo systemctl enable vsftpd
Now let’s check is the vsftpd service running or not:
sudo systemctl status vsftpd
Response:
โ vsftpd.service - Vsftpd ftp daemon
Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2019-09-03 20:57:19 +06; 3s ago
Process: 22088 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
Main PID: 22090 (vsftpd)
CGroup: /system.slice/vsftpd.service
โโ22090 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
Step 2 : Configure VSFTPD
Open the vsftpd configuration file:
sudo nano /etc/vsftpd/vsftpd.conf
Search for these lines and do the basic configuration like this:
anonymous_enable=NO
local_enable=YES
write_enable=YES
userlist_enable=YES
userlist_file=/etc/vsftpd/user_list
userlist_deny=NO
force_dot_files=YES
Now restart vsftpd:
sudo systemctl restart vsftpd
Step 3 : Secure with SSL/TLS (Optional)
If you want to enable FTP transmissions with SSL/TLS, then you can follow this step. This is an optional step.
Again open the vsftpd configuration file using this command: sudo nano /etc/vsftpd/vsftpd.conf
. Add these lines at the end of the file:
ssl_enable=YES
rsa_cert_file=/etc/vsftpd/vsftpd.pem
rsa_private_key_file=/etc/vsftpd/vsftpd.pem
You can set the path of your SSL certificate file. Or, you can generate a self-signed SSL certificate using the openssl
command:
sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/vsftpd/vsftpd.pem -out /etc/vsftpd/vsftpd.pem
Now restart vsftpd again:
sudo systemctl restart vsftpd
Step 4 : Add FTP Port to FirewalLD
If your server has FirewalLD, then you need to open FTP port 21. Let’s add the port 21 to FirewalLD by typing this command:
sudo firewall-cmd --permanent --add-port=21/tcp
# Or,
sudo firewall-cmd --permanent --add-service=ftp
Reload the firewalld:
sudo firewall-cmd --reload
If SELinux is enabled, it’s recommended to run:
sudo setsebool -P ftp_home_dir on
Step 5 : Create an FTP User
We can easily add an FTP user. Let’s create one named mynotepaper
:
sudo adduser mynotepaper
Set password for the user mynotepaper. After running this command, you’ll be asked for providing the password.
sudo passwd mynotepaper
To add the user to the allowed FTP users list, we need to run this:
sudo echo "mynotepaper" | sudo tee -a /etc/vsftpd/user_list
You can also add users by directly writing in this file: /etc/vsftpd/user_list
Md Obydullah
Software Engineer | Ethical Hacker & Cybersecurity...
Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.