- Documentation
Elastic Compute Service
Elastic Compute Service
Best Practices
Self-service website creation
Building applications
Building FTP site
Setting up FTP sites (CentOS 7.6)
Building FTP site
Setting up FTP sites (CentOS 7.6)
Setting up FTP sites (CentOS 7.6)
FTP is an application-layer protocol used for file transfer between a client and a server over a computer network. Typically, it operates on two ports: 20 and 21. This topic describes how to set up an FTP site on a CentOS 7.6 instance.
Prerequisites
- The ECS instance status is Running.
Software version
- Linux operating system: In the example provided by this topic, CentOS 7.6 is used.
- Client operating system: In the example provided by this topic, macOS Sequoia 15.6.1 is used.
- vsftpd: This topic uses vsftpd 3.0.2 as an example.
Procedure
Step 1: Install vsftpd
- Execute the following command to install vsftpd.
- Execute the following command to specify that the vsftpd automatically starts upon instance startup.
- Execute the following command to start the FTP service.
- Execute the following command to check whether the service is started.
netstat -antup | grep vsftpd
- If the following output is displayed, the vsftpd service is started.
-
tip
vsftpd allows anonymous access by default. The default FTP server path for anonymous users is /var/ftp/pub. Anonymous users only have view permissions—they cannot create, delete, or modify files or directories.
Step 2: Configure user directory
- Execute the following command to create a Linux user for the FTP service. In the example provided in this topic, the user "ftptest" is created.
- Execute the following command to set a password for user "ftptest".
tip
Enter the password as prompted, and press Enter to confirm the setting. The password is not displayed by default.
- Execute the following command to create the FTP service directory. This topic uses /home/ftp as an example.
- Execute the following command to specify the owner of the /home/ftp directory as "ftptest".
sudo chown -R ftptest:ftptest /home/ftp
Step 3: Configure vsftpd
- Execute the following command to back up the vsftpd configuration file.
sudo cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak
- Modify the vsftpd configuration file.
- Execute the following command to open the vsftpd configuration file.
sudo vim /etc/vsftpd/vsftpd.conf
- Press the i key to enter edit mode. Enable IPv4 socket listening, and disable IPv6 socket listening.
- Modify the FTP access permissions to allow only local users to access FTP and disable anonymous access.
- Modify the following configuration to enable file uploads.
- Remove the comment symbol # at the beginning of the following configuration lines. This allows you to restrict FTP user directory access using chroot jails and configure which files FTP service users can access.
chroot_list_file=/etc/vsftpd/chroot_list
- Add FTP service directory configuration and enable write permissions for users in the mounted chroot (root directory change) environment.
tip
Replace /home/ftp with the actual file directory used by the FTP service.
allow_writeable_chroot=YES
- Add the following configuration as needed to set FTP to active mode or passive mode.
tip
Due to firewall settings on most clients and other factors, the active mode may cause issues. We recommend using passive mode to set up an FTP service.
tip
Replace <PUBLIC_IP> with the actual public IP address of the server hosting the FTP site.
pasv_address=<PUBLIC_IP>
- Press the esc key to exit edit mode, enter :wq, and press the Enter key to save the changes and exit the configuration file.
- Create the chroot_list file.
- Execute the following command to create the chroot_list file.
sudo vim /etc/vsftpd/chroot_list
- Press i to enter edit mode and enter the exception user list.
tip
Users in an exception list are not restricted to their home directories and can access other directories.
- Press Esc to exit the edit mode, enter :wq, and then press Enter to save and exit the file.
- Execute the following command to restart vsftpd for the configuration to take effect.
sudo systemctl restart vsftpd
Step 4: Configure security group
After the FTP site is set up, add rules to the inbound direction of the instance security group and allow the following FTP ports. For detailed steps, refer to Changing security group rules. Step 5: Client test
You can verify the FTP service using FTP client software, a browser, a file explorer, or other tools. This topic uses MacOS Finder as an example.
- Open Finder and select "Go > Connect to Server" in the top menu bar.
- Enter ftp://ECS instance EIP:21 and click the "Connect" button.
- In the pop-up login window, confirm the FTP server information and click the "Connect" button.
- Enter the FTP username and password that have been set, and then click "Connect". After the connection succeeds, you can view the files in the specified directory on the FTP server.
warning
Since macOS "Finder" does not support uploading files to an FTP server, you can download third-party software like FileZilla to transfer files.
Last updated: 2026.06.18 17:48:26