Linux Cloud server builds FTP site

OPINION: Make the switch to a Linux operating system | Opinion |


Very Secure FTP Daemon (vsftpd) is the default FTP server for most Linux distributions. This document describes how to use the vsftpd software to build the FTP service on the CentOS 7.6 64-bit CVM.


The following software is used to build the FTP service.

  • Linux operating system: this document uses the public image CentOS 7.6 as an example.
  • Vsftpd: this document uses vsftpd 3.0.2 as an example.


Step 1: log in to the Cloud Console

Step 2: install vsftpd

  1. Run the following command to install vsftpd:yum install -y vsftpd
  2. Run the following command to enable vsftpd autostart.systemctl enable vsftpd
  3. Run the following command to start the FTP service:systemctl start vsftpd
  4. Run the following command to check that the service has been started:netstat -antup | grep ftp If the following appears, the FTP service has been successfully started.

    By default, vsftpd has enabled the anonymous access mode. This mode allows you to log in to the FTP server without entering a username or password, but you cannot modify or upload files.

Step 3: configure vsftpd

  1. Run the following command to create a Linux user (such as ftpuser) for the FTP service:useradd ftpuser
  2. Run the following command to set the password for ftpuser:passwd ftpuser After entering the password, press Enter. The password you entered will not be displayed by default. This document uses the password tf7295TFY as an example.
  3. Run the following command to create a file directory (such as /var/ftp/test) for the FTP service:mkdir /var/ftp/test
  4. Run the following command to modify the directory permission:chown -R ftpuser:ftpuser /var/ftp/test
  5. Run the following command to open the vsftpd.conf file:vim /etc/vsftpd/vsftpd.conf
  6. Press i to switch to the edit mode. Select an FTP mode as needed and modify the vsftpd.conf configuration file.
    1. Modify the following configuration parameters, set the login permissions for anonymous users and local users, set the path for storing the exceptional user list, and enable listening on IPv4 sockets.anonymous_enable=NO local_enable=YES chroot_local_user=YES chroot_list_enable=YES chroot_list_file=/etc/vsftpd/chroot_list listen=YES
    1. Add the pound sign (#) at the beginning of the following line to comment out listen_ipv6=YES and disable listening on IPv6 sockets.#listen_ipv6=YES
    2. Add the following configuration parameters, enable the passive mode, set the working directory for local users after login, and set the port range that the CVM can use to transmit data.local_root=/var/ftp/test allow_writeable_chroot=YES pasv_enable=YES # Replace with the public IP address of your Linux CVM pasv_min_port=40000 pasv_max_port=45000
  7. Press Esc and enter :wq to save and close the file.
  8. Run the following command to create and edit the chroot_list file.vim /etc/vsftpd/chroot_list
  9. Press i to enter the edit mode. Enter one username per line. After the configuration is completed, press Esc and enter :wq to save and close the file.
    If you do not need to set exceptional users, skip this step and directly enter :wq to close the file.
  10. Run the following command to restart the FTP service:systemctl restart vsftpd

Step 4: configure security groups

After building the FTP service, configure inbound rules for the Linux CVM based on the actually used FTP mode.
Most clients convert IP addresses in LANs. If you are using the FTP active mode, ensure that the client has obtained the real IP address. Otherwise, the client may fail to log in to the FTP server.

  • Active mode: open the port 21.
  • Passive mode: open the ports 21 and all ports ranging from pasv_min_port to pasv_max_port set in the configuration file, such as the ports 40000-45000 in this document.

Step 5: verify the FTP service

You can use tools such as the FTP client software, browser, or file manager to verify the FTP server. This document uses the file manager of the client as an example.

  1. Open an Internet Explorer on the client, choose Tools > Internet Options, and click the Advanced tab to modify the configuration based on the selected FTP mode.
    • Active mode: deselect Passive FTP.
    • Passive mode: select Passive FTP.
  2. Open the PC where the client is installed, type the following address in the address box of the browser, and press Enter, as shown below:ftp://CVM public IP address:21
  3. In the pop-up window, enter the username and password configured in Step 3.
    In this document, the username is ftpuser, and the password is tf7295TFY.
  4. You can upload and download files after a successful login.

No comments


Your email address will not be disclosed. The required fields are marked with*.

Related recommendation

No related articles!


Linux Cloud server builds FTP site