FTP (File Transfer Protocol) is one of the most popular methods to upload files to a server. There exists a wide array of FTP servers, such as vsftpd, that you can use, and FTP clients exist for every platform.
Essentially, no matter what OS you use, you can find an easy-to-use FTP client, so it makes for a great solution to transfer files. On CentOS-based Servers, before you can connect via FTP, you’ll have to set up an FTP server. Here we’re gonna set up vsftpd, which is a great option since it has a focus on security and speed.
These instructions are intended specifically for installing the vsfptd on CentOS 7.
You must be logged in via SSH as the root user to follow these directions.
Warning: FTP data transfer is inherently insecure; traffic is not encrypted, and all transmissions are done in clear text (including usernames, passwords, commands, and data). Consider securing your FTP connection with SSL/TLS.
Before installing new software, it’s always best practice to run updates
yum -y updateThen install vsftpd and any required packages
yum -y install vsftpdNow, let’s edit the configuration file for vsftpd. Open the file with the following command
vim /etc/vsftpd/vsftpd.confNow that the file is opened up, you’ll want to make the following changes. Either find the option line and edit it, or simply delete it and replace it with the lines noted here.
Disallow anonymous logins; this allows unidentified users to access files via FTP. Ensure that the anonymous_enable setting is set to NO
anonymous_enable=NOEnable local users to log in; this will allow your regular user accounts to function as FTP accounts. Change the local_enable setting to YES
local_enable=YESIf you want the local user to be able to write to a directory, then change the write_enable setting to YES
write_enable=YESLocal users will be ‘chroot jailed,’ and they will be denied access to any other part of the server. Set the chroot_local_user setting to YES
chroot_local_user=YESExit and save the file with the command :wq, or with :x.
First, restart the service
systemctl restart vsftpdThen set the vsftpd service to start at boot
systemctl enable vsftpdAllow the default FTP port, port 21, through firewalld
firewall-cmd --permanent --add-port=21/tcpAnd reload the firewall
firewall-cmd --reloadAnd that is it! You should now have vsftpd installed, set up, and configured on your server. If you followed these directions, you should now be able to log in to the server via FTP! The only catch is that if you have a hardware firewall in addition to the server's software firewall, you may need to adjust that too.