Setting Up an FTP Site (Linux)
Overview
The best practices for HUAWEI CLOUD ECS guide you through the setup of an FTP site on a Linux ECS using very secure FTP daemon (vsftpd). vsftpd is widely used in Linux releases, featuring compact and secure. The CentOS 7.2 64bit OS is used as an example in this section.
Procedure
- Install vsftpd.
- Log in to the ECS.
- Run the following command to install vsftpd:
If information similar to the following is displayed, vsftpd has been installed.

- Run the following command to configure automatic FTP enabling upon ECS startup:
- Run the following command to start FTP:
- Run the following command to obtain the port running FTP:
Information similar to the following is displayed.

- Configure vsftpd.
After vsftpd is installed, anonymous FTP is enabled by default, allowing you to log in to the FTP server without requiring the login username and password. However, you are not allowed to modify or upload files. If you attempt to log in to the FTP server using the Linux OS account, your request will be rejected by vsftpd, but you are allowed to configure the username and password in vsftpd for logging in to the FTP server. To do so, perform the following operations:
- Create a user.
For example, to create user ftpadmin, run the following command:
useradd ftpadmin
- Run the following command to configure the password of user ftpadmin:
passwd ftpadmin
- Run the following command to create a file directory for the FTP server, /var/ftp/work01 is used as an example:
mkdir /var/ftp/work01
- Run the following command to change the owner of the created file directory to the local user for logging in to the FTP server:
- Modify the vsftpd.conf configuration file.
- Run the following command to open the file:
- Press i to enter editing mode.
- Modify the vsftpd.conf file.
Set the active or passive FTP mode based on site requirements. If other HUAWEI CLOUD ECSs are required to use public IP addresses to access the FTP site that is set up on a HUAWEI CLOUD ECS, set the passive FTP mode.
- Parameters to be configured for 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 #No anonymous login to the FTP server is allowed. local_enable=YES #Local users are allowed to log in to the FTP server. local_root=/var/ftp/work01 #Specifies the file directory used by a local FTP user. #The following parameter allows 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 #Specifies exclusive users. allow_writeable_chroot=YES
- Additional parameters to be configured for the passive FTP mode, excluding all the parameters configured in the active FTP mode:
#The public IP address of the FTP server and the range of accessible ports must also be configured. listen=YES listen_ipv6=NO pasv_address=xx.xx.xx.xx #Public IP address of the FTP server pasv_min_port=3000 #Minimum port number in the passive FTP mode pasv_max_port=3100 #Maximum port number in the passive FTP mode
- Parameters to be configured for the active FTP mode:
- Press Esc to exit the editing mode. Then, enter :wq to save the settings and exit the configuration file.
- Create the chroot_list file in /etc/vsftpd/.
touch chroot_list
The chroot_list file contains exclusive users to whom the home directory access rules do not apply. To allow a user to access non-home directories, add the username to this file. If there is no exclusive user, the chroot_list file can be left blank, but the file must be available.
- Run the following command to restart vsftpd for the configuration to take effect:
- Create a user.
- Configure a security group.
After setting up the FTP site, add a rule in the inbound direction of the security group to allow packets to pass through the FTP port. For details, see Adding a Security Group Rule.
Enable ports based on active or passive FTP mode:
- Active FTP mode: Port 21
- Passive FTP mode: Port 21 and all ports from parameters pasv_min_port to pasv_max_port specified in the /etc/vsftpd/vsftpd.conf file
- Verify the configuration on the client.
On the computer with the client installed, enter fttp://IP address of the FTP server:FTP port number in the Internet Explorer address bar. If you do not specify the port number, default port number 21 is used. 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 the 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, you are advised to clear the browser caches and try again.
Last Article: Setting Up an FTP Site (Windows)
Next Article: Manually Deploying Java Web
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.