Very secure FTP daemon (vsftpd) is a lightweight, safe, and easy-to-use FTP server software for Linux. This topic describes how to install and configure vsftpd on a Linux Elastic Compute Service (ECS) instance.
Prerequisites
An ECS instance is created and assigned a public IP address. If no ECS instance is created, create an ECS instance. For more information, see Creation method overview.
Background information
FTP is a protocol used to transfer files. FTP is built on a client-server model architecture and supports the following working modes:
- Active mode: The client sends port information to the FTP server, and the server establishes a connection to the port.
- Passive mode: The FTP server enables a port and sends the port information to the client. The client initiates a connection to the port, and the server accepts the connection.
FTP supports the following authentication modes:
- Anonymous user mode: In this mode, users can log on to the FTP server without a username or password. This is the least secure authentication mode. In most cases, this mode is used to save unimportant public files. We recommend that you do not use this mode to save files in a production environment
- Local user mode: This authentication mode requires users to have local Linux accounts. This mode is more secure than the anonymous user mode.
- Virtual user mode: Virtual users are dedicated users of the FTP server. Virtual users can access only the FTP service that the Linux system provides. Virtual users cannot access other resources of the system. This way, the security of the FTP server is further enhanced.
In this topic, vsftpd is configured in passive and local user mode. For information about how to configure an FTP server to allow anonymous users to access the FTP server and information about how to use the tools on third-party FTP clients, see FAQ.
- Instance type: ecs.c6.large
- Operating system: CentOS 7.2 64-bit
- vsftpd: 3.0.2
The commands and parameters used in this topic may vary based on your resources.
Step 1: Install vsftpd
Step 2: Configure vsftpd
In this example, vsftpd is configured in passive and local user mode to ensure data security.
Step 3: Configure security groups
Rule direction | Authorization policy | Protocol type | Port range | Authorized object |
---|---|---|---|---|
Inbound | Allow | Custom TCP | 21/21 | The public IP addresses in CIDR block notation of all clients that need to access
the FTP server. Separate the IP addresses with commas (,).
To allow all clients to access the FTP server, specify 0.0.0.0/0 as an authorization object. |
Inbound | Allow | Custom TCP | pasv_min_port/pasv_max_port. Example: 50000/50010. | The public IP addresses in CIDR block notation of all clients that need to access
the FTP server. Separate the IP addresses with commas (,).
To allow all clients to access the FTP server, specify 0.0.0.0/0 as an authorization object. |
Step 4: Check whether you can access the FTP server from the client
To check whether FTP servers are accessible, you can use FTP clients, Windows command-line tools, or browsers. In this example, a host that runs Windows Server 2012 R2 64-bit operating system is used to describe how to access an FTP server.
vsftpd configuration file and parameters
- /etc/vsftpd/vsftpd.conf is the core configuration file of vsftpd.
- /etc/vsftpd/ftpusers is the blacklist file. Users specified in this file are not allowed to access the FTP server.
- /etc/vsftpd/user_list is the whitelist file. Users specified in this file are allowed to access the FTP server.
- The following table describes the parameters for logon control.
Parameter setting Description anonymous_enable=YES Accepts anonymous users. no_anon_password=YES Anonymous users do not need a password to log on to the FTP server. anon_root= (none) Specifies the home directory of anonymous users. local_enable=YES Accepts local users. local_root= (none) Specifies the home directory of local users. - The following table describes the parameters that are used to manage the permissions
of users.
Parameter setting Description write_enable=YES Allows all users to upload files. local_umask=022 Grants local users the permission to upload files. file_open_mode=0666 Uses umask for permissions to upload files. anon_upload_enable=NO Allows anonymous users to upload files. anon_mkdir_write_enable=NO Allows anonymous users to create directories. anon_other_write_enable=NO Allows anonymous users to modify and delete files. chown_username=lightwiter Specifies the ownership of files that are uploaded by anonymous users.
FAQ
- Question 1: What do I do if I am unable to download files from the FTP server when
the local host runs a Windows operating system?
Answer: You must perform the following operations to enable the download permission in Internet Explorer.
- Open Internet Explorer in your local host.
- Click the
icon in the upper-right corner of the browser, and then click Internet Options.
- At the top of the Internet Options dialog box, click the Security tab.
- In the Select a zone to view or change security settings. section, click Internet, and then click Custom level... in the Security level for this zone section.
- Choose OK. , and then click
- Click Apply and then click OK.
- Question 2: What do I do if an error is reported when I use a command-line tool or
a browser to connect to an FTP server on Windows?
Answer: You can manually troubleshoot the problem based on the error message about the FTP server. If the problem is difficult to troubleshoot, we recommend that you use a third-party FTP client connection tool such as FileZilla. You can download FileZilla from FileZilla. In this example, FileZilla is used to connect to an FTP server in anonymous mode.
- On the FTP server on Linux, install vsftpd.
For more information, see Step 1: Install vsftpd. If vsftpd is installed, skip this step.
- Configure vsftpd as anonymous mode.
- Run the following command to modify the /etc/vsftpd/vsftpd.conf configuration file.
If you use the
apt install vsftpd
command to install vsftpd, the path of the configuration file is /etc/vsftpd.conf.vim /etc/vsftpd/vsftpd.conf
- Press the I key to enter the edit mode.
- Comment out the permissions and set
anon_upload_enable
to YES to allow anonymous users to upload files. - Press the Esc key to exit the edit mode. Enter :wq and press the Enter key to save and close the file.
The following figure shows the modified configuration file.
- Run the following command to change the permissions of the /var/ftp/pub directory and grant write permissions to FTP users:
/var/ftp/pub is the default file directory of the FTP service.
chmod o+w /var/ftp/pub/
- Run the following command to reload the configuration file:
systemctl restart vsftpd.service
- Run the following command to modify the /etc/vsftpd/vsftpd.conf configuration file.
- Download and install FileZilla.
- Use FileZilla to connect to the FTP server in anonymous mode.
- Open the FileZilla client.
- In the top navigation bar, choose .
- In the lower-left corner of the Site Manager dialog box, click New site.
- Enter a name for the new site and configure the new site.
The following list describes the parameters:
- Name: a custom site name. Example,
test-01
. - Protocol: FTP.
- Host: the public IP address of the FTP server. In this topic, the value is the public
IP address of the Linux instance. For example,
121.43.XX.XX
. - Port: 21.
- Logon Type: Anonymous.
In this example, an FTP client is used to connect to the FTP server in anonymous mode. If you want to manage access to the FTP server, set the logon type to normal and configure the username and password.
- Name: a custom site name. Example,
- Click Connect.
After the FTP server is connected to, you can upload, download, and delete files. The FileZilla interface is shown in the following figure.
The following table describes the sections in the preceding interface.
No. Description ① Commands, the connection status of the FTP server, and task execution results are shown. ② The section for the information about the local host, in which the directory information of the local host is shown. ③ The section for the information about the remote server, in which the directory information of the FTP server is shown. In anonymous mode, the default directory is /pub. ④ The section for records, in which the queues and logs of the FTP task are shown.
- On the FTP server on Linux, install vsftpd.