Updated on 2025-08-06 GMT+08:00

Setting Up an FTP Site (Ubuntu)

Scenarios

This section guides you through the setup of an FTP site on a Linux ECS using vsftpd. vsftpd is an FTP server software that is widely used in Linux releases. Ubuntu 22.04 (64-bit) is used as an example in this section.

Solution Architecture

Figure 1 Setting up an FTP site (Ubuntu)

Advantages

  • A website with a simple networking architecture can be quickly set up.
  • The website is secure and easy to use.

Resource Planning

Table 1 Resources and costs

Resource

Description

Cost

VPC

VPC CIDR block: 192.168.0.0/16

Free

VPC subnet

  • AZ: AZ1
  • CIDR block: 192.168.0.0/24

Free

Security group

Inbound rule (active mode):
  • Priority: 1
  • Action: Allow
  • Type: IPv4
  • Protocol & Port: TCP: 20-21
  • Source: 0.0.0.0/0
Inbound rule (passive mode):
  • Priority: 1
  • Action: Allow
  • Type: IPv4
  • Protocol & Port: TCP: 21 and ports configured in vsftpdconf
  • Source: 0.0.0.0/0

Free

ECS

  • Billing mode: Yearly/Monthly
  • AZ: AZ1
  • Flavor: s6.large.4
  • Image: Ubuntu 22.04 64-bit
  • System disk: 40 GiB
  • EIP: Auto assign
  • EIP type: Dynamic BGP
  • Billed by: Traffic
  • Bandwidth: 5 Mbit/s

The following resources generate costs:

  • ECSs
  • EVS disks
  • EIP

For billing details, see Billing Modes.

vsftpd

A free, open-source FTP software.

Free

Process

The process of manually setting up an FTP website on a Linux ECS is as follows:
  1. Install vsftpd.
  2. Configure vsftpd.
  3. Configure the user directory.
  4. Configure a security group.
  5. Verify the configuration on the client.

Procedure

  1. Log in to the ECS.
  2. Install vsftp.

    1. Run the following commands to install vsftpd:
      sudo apt-get update
      sudo apt-get install vsftpd

      If Do you want to continue? [Y/n] is displayed, enter y or Y to continue the installation.

    2. Run the following command to back up the original configuration file:
      sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak

  3. Configure vsftp.

    1. Modify the vsftpd.conf configuration file.
      1. Run the following command to open the vsftpd.conf file:
        sudo vim /etc/vsftpd.conf
      2. Press i to enter insert mode.
      3. Modify the vsftpd.conf file.

        Set FTP to active or passive mode based on site requirements. If other Huawei Cloud ECSs need to use EIPs to access the FTP server that is set up on a Huawei Cloud ECS, set FTP to passive mode.

        • Parameters for configuring the active FTP mode:
          #No anonymous login to the FTP server is allowed. Local users are allowed to log in to the FTP server with their local file directories specified.
          anonymous_enable=NO              #Anonymous login to the FTP server is not allowed.
          local_enable=YES                 #Local users are allowed to log in to the FTP server.
          write_enable=YES                 #File upload is enabled.
          
          #The following parameters only allow login users to visit their own home directories:
          chroot_local_user=YES                      #The directory access rule applies to all users.
          chroot_list_enable=YES                     #The directory access rule does not apply to exclusive users.
          chroot_list_file=/etc/vsftpd/chroot_list   #Exclusive users.
          
          #Add the following parameters to configure the FTP directory.
          local_root=/home/ftp 
          allow_writeable_chroot=YES
        • The passive FTP mode requires not only all the parameters configured for the active FTP mode, but also include the following parameter settings:
          #Set the following parameters to enable the passive mode and specify the range of ports opened for the FTP server.
          pasv_min_port=35000            #Minimum port number in passive FTP mode
          pasv_max_port=40000            #Maximum port number in passive FTP mode
      4. Press Esc to exit insert mode. Then, enter :wq to save the settings and exit.
    2. Run the following command to restart vsftpd to apply the setting:
      sudo systemctl restart vsftpd

  4. Configure the user directory.

    1. After FTP is installed, a user named ftp is created by default. The user does not have a password. Run the following command to reset the password of ftp:
      sudo passwd ftp
    2. Run the following command to add the user to the list of allowed FTP users:
      echo "ftp" | sudo tee -a /etc/vsftpd.userlist
    3. Run the following commands to create an FTP file directory and grant permissions to the user:
      sudo mkdir /home/ftp
      sudo chmod 777 /home/ftp

  5. Configure a security group.

    After setting up the FTP site, add an inbound rule to the security group to allow packets to pass through the FTP port. For details, see Adding a Security Group Rule.

    Table 2 Security group rules

    Priority

    Action

    Type

    Protocol & Port

    Source

    1

    Allow

    IPv4

    Protocols/TCP (Custom): 21

    0.0.0.0/0

    1

    Allow

    IPv4

    Protocols/TCP (Custom): 1024-65535 (for example, 35000-40000)

    0.0.0.0/0

  6. Verify the configuration on the client.

    On the computer with the client installed, enter ftp://<server-IP-address>:<FTP-port-number> in the address bar. If you do not specify the port number, port 21 is used by default. If a dialog box is displayed for you to enter the username and password, the configuration is correct. After entering the username and password, you can perform operations on the FTP folder with assigned permissions.

    • If active FTP mode is selected, use this method to configure the Internet Explorer browser. Otherwise, the FTP folder will be inaccessible. To configure the Internet Explorer browser, choose Tools > Internet Options > Advanced, select Enable FTP folder view, and deselect Use Passive FTP.
    • If an error occurs when you use a browser to access the FTP server, clear the browser caches and try again.