Elastic Cloud Server

Setting up an FTP Site on Linux

2025-11-26 08:44:14

Operation Steps to Manually Build an FTP Site Using the Linux Instance

1. Install vsftpd

2. Configure vsftpd

3. Set up security group

4. Client test

Example Environment

Instance type: s3.large.2 | 2-core | 4G general purpose cloud server

Region: Shanxi

System disk: 40GB

Operating system: CentOS7.2 64-bit

Elastic IP bandwidth: 1Mbps

Procedure

1. Install vsftpd

a. Log in to the Elastic Cloud Server.

b. Execute the following command to install vsftpd, yum install -y vsftpd, and if the echo message is as follows, then the software is installed successfully.
c. Execute the following command to set the FTP service to start at boot.

systemctl enable vsftpd.service

d. Execute the following command to start the FTP service.

systemctl start vsftpd.service
e. Execute the following command to check the FTP service port.

netstat -antup | grep ftp

The echo message is as follows.

2. Configure vsftpd

vsftpd is installed with anonymous FTP enabled by default. With anonymous FTP, users can log in to the FTP server without entering username and password, but do not have permission to modify or upload files. If a user tries to log in to the server with an account in the Linux operating system, it will be rejected by vsftpd, but the user account and password can be configured in vsftpd to log in. The following is an example of configuring a user account and password in vsftpd to log in to the FTP server.

a. Execute the following command to create the "ftptest" user. Here the "ftptest" user is an example, you can create the appropriate user according to the actual situation.

useradd ftptest
b. Execute the following command and follow the prompts to set the "ftptest" user password "passwd ftptest" and enter the password.

c. Execute the following command to create a file directory for FTP, taking "/var/ftp/test" as an example.
mkdir /var/ftp/test

d. Execute the following command to change the owner of the created file directory to a local user used to log in to FTP.
chown -R ftptest:ftptest /var/ftp/test

e. Modify the vsftpd.conf configuration file.

Run the following command to open the configuration file.
"vsftpd.conf", vi /etc/vsftpd/vsftpd.conf

Press i to enter Edit mode.

Modify the opened vsftpd.conf file.

anonymous_enable=YES #Enable anonymous user access. Enabled by default.
write_enable=YES #Open write access to the server (To upload, it must be enabled). Enabled by default.
anon_umask=022 #Set the permission mask (wildcard mask) for anonymous users to upload data. Enabled by default.
anon_upload_enable=YES #Allow anonymous users to upload files. It is commented by default, and needs to be uncommented.
anon_mkdir_write_enable=YES #Allow anonymous users to create (upload) directories. It is commented by default, and needs to be uncommented.
anon_other_write_enable =YES #Allow delete, rename, overwrite, etc. It needs to be added.

f. Press Esc to exit Edit mode and type :wq to save and exit.

g. Execute the following command to restart the vsftpd service for the configuration to take effect.
systemctl restart vsftpd.service

h. Disable firewalls and enhanced security features.
systemctl stop firewalld
setenforce 0

3. Set up security group

After setting up the FTP site, you need to configure the security group rules of the ECS, add a rule to allow the FTP port in the inbound direction, and set the security group rules as shown in the following table.

FTP Mode

Direction

Protocol

Port

Source Address

Active Mode

Inbound

TCP

Port 20 and Port 21

0.0.0.0/0

Passive Mode

Inbound

TCP

Port 21 and all ports between the parameters "pasv_min_port" and "pasv_max_port" in the configuration file /etc/vsftpd/vsftpd.conf

0.0.0.0/0


4. Client test
a. In Windows, open the Start menu and enter cmd to open the command prompt.
b. Establish ftp connection: ftp XX.XX.XX.XX (VM public IP address).
c. Enter the configured user name and password. If the following information is displayed, the access is successful.
d. ftp> pwd #The root directory for anonymous access to ftp is the /var/ftp/ directory of the Linux system.
e. ftp> ls #View the current directory.
f. Open the client computer and enter "ftp://FTP server IP address: FTP port" in the path bar (if the port is not filled in, port 21 will be accessed by default). The dialog box for entering the user name and password is displayed, indicating that the configuration is successful. After you enter the correct user name and password, you can perform corresponding operations on the FTP file.

The file directory is the same on the Linux cloud server.


OLSsa.Y5f1FH