Overview
Very Secure FTP Daemon (vsftpd) is the default FTP server for most Linux distributions. This document describes how to use vsftpd to build the FTP service on a Linux CVM with CentOS 7.6 64-bit installed.
Software
The following software is used to build the FTP service.
Linux operating system: CentOS 7.6 public image
Vsftpd: vsftpd 3.0.2
Directions
Step 1: log in to the CVM
Step 2: install vsftpd
1. Run the following command to install vsftpd.
2. Run the following command to automatically start vsftpd upon system startup.
3. Run the following command to start the FTP service.
4. Run the following command to check that the service has been started.
netstat -antup | grep ftp
If the following information appears, the FTP service has been started.
By default, vsftpd has enabled the anonymous access mode. You can log in to the FTP server without entering a username and password. However, you do not have permissions to modify or upload files in this login mode. Step 3: configure vsftpd
1. Run the following command to create a Linux user (such as ftpuser) for the FTP service.
2. Run the following command to set the password for ftpuser.
After entering the password, press Enter to confirm. By default, the password is not displayed. This document uses tf7295TFY
as a password sample.
3. Run the following command to create a file directory (such as /var/ftp/test
) for the FTP service.
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.
Note:
The FTP server can connect to the client in either active or passive mode for data transmission. Due to the firewall settings of most clients and the fact that the actual IP address cannot be obtained, we recommend that you use the passive mode to set up the FTP service. The following modification uses the passive mode as an example. To use the active mode, see Setting the FTP active mode. 6.1 Modify the following configuration parameters to set login permissions for anonymous and local users, set the path for storing the exceptional user list, and enable listening on IPv4 sockets.
anonymous_enable=NO
local_enable=YES
write_enable=YES
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
listen=YES
6.2 Add the pound sign (#
) at the beginning of the following line to comment out listen_ipv6=YES
and disable listening on IPv6 sockets.
6.3 Add the following configuration parameters to enable the passive mode, set the directory where local users reside after login, and set the port range for transmitting data by the CVM.
local_root=/var/ftp/test
allow_writeable_chroot=YES
pasv_enable=YES
pasv_address=xxx.xx.xxx.xx
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 and enter usernames. Note that each username occupies one line. After finishing the configuration, press Esc and enter :wq to save and close the file.
The specified users will not be restricted to access only the root directory. If you do not need to set exceptional users, skip this step by entering :wq to close the file.
10. Run the following command to restart the FTP service.
After setting up the FTP service, configure inbound rules for the Linux CVM based on the actually used FTP mode. For more information, see Adding Security Group Rules.
Most clients convert IP addresses in LANs. If you are using the FTP active mode, ensure that the client has obtained the actual IP address. Otherwise, the client may fail to log in to the FTP server. Active mode: open port 21.
Passive mode: open port 21 and all ports ranging from pasv_min_port
to pasv_max_port
set in the configuration file, such as ports 40000 to 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 Internet Explorer on the client, choose Tools > Internet Options, and click the Advanced tab. Make the following modifications based on the selected FTP mode.
For the active mode: deselect Passive FTP.
For the 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. On the login page that appears, enter the username and password set in Configure vsftpd.
Here, the username is ftpuser
, and the password is tf7295TFY
. 4. You can upload and download files after a successful login.
Appendix
Setting the FTP active mode
To use the active mode, modify the following configuration parameters and leave others as their defaults:
anonymous_enable=NO
local_enable=YES
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
listen=YES
allow_writeable_chroot=YES
local_root=/var/ftp/test
Press Esc and enter :wq to save and close the file. After that, go to Step 8 to configure vsftpd. FTP client failed to upload files
Cause
In the Linux environment, users encounter the following error message when uploading files with vsftpd.
553 Could not create file
Solution
1. Run the following command to check the disk space utilization of the server.
If the disk space is insufficient, you cannot upload files. In this case, we recommend that you delete some unnecessary large files from the disk.
If the disk space is sufficient, go to the next step.
2. Run the following command to check whether you have the write permission to the FTP directory.
If w
is not returned in the result, you do not have the write permission to the directory. In this case, go to the next step.
If w
is returned in the result, submit a ticket
for further troubleshooting. 3. Run the following command to grant the write permission to the FTP directory.
4. Run the following command to check whether the write permission is successfully granted:
Was this page helpful?