Install vsftpd
Use yum to install the FTP server package:
sudo yum install -y vsftpd
Enable vsftpd at Boot
After installation, configure the service to start automatically when the system boots:
sudo systemctl enable vsftpd
Start the FTP Service
Start vsftpd with systemctl:
sudo systemctl start vsftpd
Check Whether the Service Is Running
You can verify the FTP service status by checking the listening ports:
sudo netstat -antup | grep ftp
Create an FTP User
Create a local user for FTP access. The following example creates a user named admin:
sudo useradd admin
Then set a password for this user:
sudo passwd admin
Create the FTP Directory
Create a directory that will be used as the FTP file directory:
sudo mkdir /var/ftp/admin
Change the ownership of the directory so that the admin user can access it:
sudo chown -R admin:admin /var/ftp/admin
Edit the vsftpd Configuration
Open the main vsftpd configuration file:
sudo vim /etc/vsftpd/vsftpd.conf
Press i to enter insert mode in Vim.
Modify the following configuration items:
anonymous_enable=NO
local_enable=YES
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
listen=YES
Add these settings:
local_root=/var/ftp/admin
allow_writeable_chroot=YES
pasv_enable=YES
pasv_address=xxx.xx.xxx.xx #修改为公网 IP
pasv_min_port=40000
pasv_max_port=45000
Comment out the IPv6 listening option:
#listen_ipv6=YES
When finished, press Esc, then enter :wq to save and exit.
Create the chroot_list File
Create and edit the chroot_list file:
sudo vim /etc/vsftpd/chroot_list
Press i to enter insert mode. Add one username per line, for example:
admin
root
After editing, press Esc, then enter :wq to save and exit.
Restart vsftpd
Restart the FTP service so the configuration changes take effect:
sudo systemctl restart vsftpd