All Products
Search
Document Center

Elastic Compute Service:Build an FTP server on a Linux instance

Last Updated:May 15, 2026

Install and configure vsftpd on a Linux ECS instance to enable secure FTP file transfers.

Quick deployment

Click Run now to open Terraform Explorer and automatically build an FTP site on an ECS instance.

Prerequisites

An ECS instance that meets the following requirements is created. To create one, see Create an instance using the wizard.

  • Operating system: Alibaba Cloud Linux 3/2, CentOS 7.x 64-bit, Ubuntu, or Debian.

  • IP address: The instance has a static public IP address or an associated EIP. See Elastic IP Address.

Overview

vsftpd (Very Secure FTP Daemon) is an open-source FTP server for UNIX and Linux systems. Key features:

  • High security: strict security audits and multiple mechanisms to prevent common attacks.

  • High performance: handles many concurrent connections with efficient file transfers.

  • Simple configuration: flexible, easy-to-understand options for various needs.

  • IPv6 support: native support for IPv6 networks.

Build the VSFTP service

Alibaba Cloud Linux 3 and 2/CentOS 7.x

Step 1: Install vsftpd

  1. Update the system and install vsftpd.

    sudo yum update -y 
    sudo yum install vsftpd -y
  2. Start the FTP service and enable auto-start on boot.

    sudo systemctl start vsftpd
    sudo systemctl enable vsftpd 
  3. Check whether the service is started.

    netstat -antup | grep ftp

    Output similar to the following indicates the FTP service started successfully.

    image

    By default, vsftpd enables anonymous access. Anonymous users can log on without credentials but cannot modify or upload files.

Step 2: Configure vsftpd

  1. Create a dedicated FTP user and set a password. This example uses ftpuser.

    sudo useradd -d /data/ftp -s /sbin/nologin ftpuser  # Specify the home directory and disable shell access
    sudo passwd ftpuser 
  2. Create the FTP directory and set permissions.

    sudo mkdir -p /data/ftp      # Create a custom storage directory
    sudo chown ftpuser:ftpuser /data/ftp
    sudo chmod 750 /data/ftp    # Permissions must be 755 or 750
  3. Edit the vsftpd configuration file.

    Note

    FTP supports active and passive modes. Passive mode is recommended because most clients are behind firewalls or NAT and cannot expose their real IP addresses.

    1. Back up the vsftpd configuration file.

      sudo cp /etc/vsftpd/vsftpd.conf  /etc/vsftpd/vsftpd.conf.bak
    2. Edit the configuration file.

      sudo vim /etc/vsftpd/vsftpd.conf
    3. Set the basic security configuration.

      listen=YES                   # Enable IPv4 listener
      anonymous_enable=NO          # Disable anonymous access
      local_enable=YES             # Enable local user logon
      write_enable=YES             # Allow file uploads
      chroot_local_user=YES        # Lock users to their home directory
      allow_writeable_chroot=YES   # Resolve chroot write errors
    4. Append the passive mode configuration.

      pasv_enable=YES              # Enable passive mode
      pasv_min_port=40000          # Lower limit of the passive port range
      pasv_max_port=40100          # Upper limit of the passive port range
      pasv_address=public_ip_address      # Must be set to the server's public IP address
  4. Restart vsftpd.

    sudo systemctl restart vsftpd

Step 3: Set security group rules

After building the FTP service, add inbound security group rules based on the FTP mode. See Add a security group rule.

Most clients are behind a LAN with translated IP addresses. In active mode, clients must expose their real IP addresses, or FTP connections may fail.

  • Active mode: Allow traffic on port 21.

  • Passive mode: Allow traffic on port 21 and ports 40000–40100 (the pasv_min_port to pasv_max_port range in /etc/vsftpd/vsftpd.conf). See Configuring FTP passive mode ports.

Step 4: Verify the FTP service

You can verify the FTP service with an FTP client, a browser, or a file explorer. This example uses the file explorer.

  1. Test the local connection.

    Test the connection from the local machine.

    ftp ftpuser@localhost 

    A Login successful message indicates a successful connection.

    image

  2. Test the client connection.

    On the client computer, open the file explorer and enter the FTP address, as shown in the figure.

    image

    Enter the FTP username and password in the logon dialog box. After logging on, you can upload and download files.

Ubuntu and Debian

Step 1: Install VSFTP

  1. Update the system and install vsftpd.

    sudo apt update && sudo apt upgrade -y
    sudo apt install vsftpd -y
  2. Start vsftpd and enable auto-start on boot.

    sudo systemctl start vsftpd
    sudo systemctl enable vsftpd

Step 2: Configure VSFTP

  1. Create a dedicated FTP user.

    sudo useradd -m -s /bin/bash ftpuser  # Create a user and automatically generate a home directory
    sudo passwd ftpuser  # Set the user password (a strong password is recommended)
  2. Create the file storage directory and set permissions.

    sudo mkdir /home/ftpuser/ftp-files
    sudo chown ftpuser:ftpuser /home/ftpuser/ftp-files
    sudo chmod 755 /home/ftpuser/ftp-files
  3. Back up the original configuration file.

    sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak
  4. Edit the configuration file.

    sudo nano /etc/vsftpd.conf

    Apply the following settings:

    # Basic configuration
    listen=YES
    anonymous_enable=NO          # Disable anonymous access
    local_enable=YES             # Allow local user logon
    write_enable=YES             # Enable write permissions
    chroot_local_user=YES        # Lock users in their home directory

    Append the following to the file:

    allow_writeable_chroot=YES   # Allow writing to the chroot directory
    local_root=/home/ftpuser/ftp-files  # Specify the root directory for the FTP user
    
    # Passive mode configuration (to resolve external network connection issues)
    pasv_enable=YES
    pasv_address=xx.xx.xx.xx  # Replace with your public IP address
    pasv_min_port=40000
    pasv_max_port=40100
  5. Restart the FTP service.

    sudo systemctl restart vsftpd
  6. A default user named ftp is created without a password during FTP installation. Change the password for this user.

     sudo passwd ftp

    Set a strong password and skip all other prompts.

  7. Add the user to the FTP user allowlist.

     echo "ftp" | sudo tee -a /etc/vsftpd.userlist
  8. Create an FTP file directory and grant user permissions.

    1. Create an FTP folder.

       sudo mkdir /home/ftp
    2. Set folder ownership.

      This example grants read, write, and full control permissions. Adjust as needed.
       sudo chmod 777 /home/ftp

Step 3: Set security group rules

After building the FTP service, add inbound security group rules based on the FTP mode. See Add a security group rule.

Most clients are behind a LAN with translated IP addresses. In active mode, clients must expose their real IP addresses, or FTP connections may fail.

  • Active mode: Allow traffic on port 21.

  • Passive mode: Allow traffic on port 21 and ports 40000–40100 (the pasv_min_port to pasv_max_port range in /etc/vsftpd/vsftpd.conf). See Set up an FTP site on Windows.

Step 4: Verify the FTP service

You can verify the FTP service with an FTP client, a browser, or a file explorer. This example uses the file explorer.

  1. Test the local connection.

    Test the connection from the local machine.

    ftp ftpuser@localhost 

    A Login successful message indicates a successful connection.

    image

  2. Test the client connection.

    On the client computer, open the file explorer and enter the FTP address, as shown in the figure.

    image

    Enter the FTP username and password in the logon dialog box. After logging on, you can upload and download files.

Troubleshooting

Issue

Solution

Timeout after 227 Entering Passive Mode

Check the public IP address and firewall rules on both client and server.

550 Permission denied

Set directory permissions to 755.

Only empty directories are listed

Check the chroot_local_user configuration.

500 OOPS: vsftpd: refusing to run with writable root

Run chmod a-w /data/ftp.

Passive mode connection timeout

Check firewall rules and the pasv_address setting.

Cannot upload files

Verify directory permissions are 755 or 750.

Appendix

vsftpd configuration file and parameters

Files in the /etc/vsftpd directory:

  • /etc/vsftpd/vsftpd.conf: Core vsftpd configuration file.

  • /etc/vsftpd/ftpusers: Blacklist file. Users in this file cannot access the FTP server.

  • /etc/vsftpd/user_list: Whitelist file. Users in this file can access the FTP server.

Parameters in the vsftpd.conf configuration file:

  • Logon control parameters:

    Parameter

    Description

    anonymous_enable=YES

    Accepts anonymous users.

    no_anon_password=YES

    Anonymous users can log on without a password.

    anon_root=(none)

    Home directory for anonymous users.

    local_enable=YES

    Accepts local users.

    local_root=(none)

    Home directory for local users.

  • User permission control parameters:

    Parameter

    Description

    write_enable=YES

    Allows file uploads (global).

    local_umask=022

    File permissions for local user uploads.

    file_open_mode=0666

    File permissions for uploads. Works with local_umask.

    anon_upload_enable=NO

    Anonymous users can upload files.

    anon_mkdir_write_enable=NO

    Anonymous users can create directories.

    anon_other_write_enable=NO

    Anonymous user: edit and delete permissions.

    chown_username=lightwiter

    Username for anonymous file uploads.