- Documentation
Elastic Compute Service
Elastic Compute Service
Best Practices
Self-service website creation
Building applications
Building FTP site
Setting up FTP sites (Ubuntu 22.04)
Building FTP site
Setting up FTP sites (Ubuntu 22.04)
Setting up FTP sites (Ubuntu 22.04)
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 Ubuntu 22.04 instance.
- The ECS instance status is Running.
- Linux operating system: This topic uses Ubuntu 22.04 as an example.
- Client operating system: This topic uses macOS Sequoia 15.6.1 as an example.
- vsftpd: This topic uses vsftpd 3.0.2 as an example.
- Execute the following commands 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.
- 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 vsftpd
- Execute the following command to back up the vsftpd configuration file.
- Modify the vsftpd configuration file.
- Execute the following command to open the vsftpd configuration file.
- 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.
- Add FTP service directory configuration and enable write permissions for users in the mounted chroot (root directory change) environment.
- 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.
- 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 a chroot_list file, and add the list of exception usernames to the file.
tip
Users in an exception list are not restricted to their home directories and can access other directories.
- Execute the following command to create the chroot_list file.
- Press i to enter edit mode and enter the exception user list.
- 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.
Step 3: Configure user directory
- After you install vsftpd, a default passwordless user named ftp is created. Execute the following command to modify the password.
- If the following output is displayed, the login password for user ftp is modified.
-
- Execute the following command to ensure that the shell of user ftp is included in the /etc/shells file.
- Execute the following command to add the user ftp to the vsftpd list of users allowed to log in.
- Execute the following command to create the FTP file directory.
- Execute the following command to grant permissions for the FTP file directory.
tip
In the example provided in this topic, read, write, and full control permissions on the folder are granted. Modify the corresponding permissions as needed.
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. 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:27