Vsftpd installation and configuration tutorial, vsftpd configuration tutorial
Vsftpd is used for image server using ftp. It is relatively simple to install, but there are several problems in the process. To prevent future use, record the entire process.
Install
First, I use the ubuntu system. Install vsftpd and run the following command:
sudo apt-get install vsftpd
After the installation is complete, check whether the corresponding port is open. ftp uses port 21:
netstat -npltu | grep 21
Log on.
After the installation is complete, you can log on locally. The logon command is as follows:
ftp localhost
Then there is an interface for entering the account and password. Because I am using a virtual machine for learning, there is no need to set up multiple accounts, so I often use root directly to reduce some permissions.
However, when I enter the root account and password, the following problems occur:
The problem is:
331 Please specify the password.
530 Login incorrect.
I did not log in correctly, but I was able to confirm that the account and password were correct. Then I checked and found that someone had the same problem on the Internet, however, the solution is to directly delete/etc/pam. d/vsftpd:
Because PAM is enabled in ubuntu, you need to use the/etc/pam. d/vsftpd file when using vsftpd. It is also said that this file will not be available when the default source code is installed. Therefore, in addition to anonymous access by an outdoor local user, the file cannot be logged in. Then, the file is deleted, and a 331 Please specify the password solution appears for connecting to ftp.
I tried to delete the file and can log on to it. But later I thought it was not quite right. Since it was a file under etc, that is, a configuration file, it certainly exists and should not be deleted for no reason. Then uninstall and reinstall the instance and review the problem.
Now we know that this problem is caused by PAM, but it is not clear to me what PAM is, and I have probably checked the information. I can refer to this article: basic concepts and architecture of PAM-Linux Pluggable Authentication Module
The entire process from this to PAM is: the plug-in Authentication Module-PAM mechanism allows users to easily Insert new Authentication modules or replace the original components in the application.
Now the idea is clear. When using Vsftpd, ubuntu will enable the PAM module (as to whether to enable the PAM module through source code installation, I have no experiment, so I cannot confirm ), use the new authentication mechanism. However, the root user cannot log on because of this authentication mechanism, so we should check what the authentication mechanism has done and view the/etc/pam. d/vsftpd file:
Deny (deny) and a file are found. Try to view the/etc/ftpusers file:
By the way, the problem is that root exists in the list that does not allow access to ftp, and then the root user is deleted and logged on again. The login is successful:
You can also use PAM to configure virtual users for ftp. This article provides a comprehensive introduction to vsftpd: Vsftpd, which also mentions the problem of the above root user. Unfortunately, it was discovered after the solution, otherwise there will be a lot of time left.
Use FileZilla to transfer files.
Now that the root login problem has been solved, we will start to use vsftpd. The Client Connecting to ftp uses FileZilla.
Now that the connection is successful, double-click the local file to upload the file, but there is a problem when uploading the file:
If the transmission fails, you need to configure some content in/etc/vsftpd. conf to enable the file transmission Configuration:
Save the configuration and restart vsftpd:
service vsftpd restart
After restart, you can upload and download files normally.