1. Create a virtual user password library file # vi/etc/vsftpd/login.txt Add the user name and password (the odd line is the user name, and the even line is the password ): ftp_test123456wq save exit II. Generate vsftpd authentication file # db_load-T-thash-f/etc
1. Create a virtual user password Library File
- # Vi/etc/vsftpd/login.txt
Add the username and password (the odd line is the username, and the even line is the password ):
Ftp_test
123456
Wq save and exit
Ii. Generate vsftpd Authentication Files
- # Db_load-T-t hash-f/etc/vsftpd/login.txt/etc/vsftpd/login. db
If you are prompted that the db_load command is not available, install the db4-utils first:
- # Yum install db4-utils
3. Set the authentication file to be readable and writable only to the root user
- # Chmod 600/etc/vsftpd/login. db
4. Create the PAM Configuration File required by the virtual user and manually create the vsftpd. vu File
- # Vi/etc/pam. d/vsftpd. vu
Input:
- Uth required pam_userdb.so db =/etc/vsftpd/login
- Account required pam_userdb.so db =/etc/vsftpd/login
Note: Do not add a path before pam_userdb.so.
5. Create a system user account used by all FTP virtual user accounts and Set permissions for the home directory of the account
- # Useradd-d/home/vsftp-s/sbin/nologin vftp
6. Configure the vsftpd. conf file
- # Vi/etc/vsftpd. conf
Modify and add content:
- Anonymous_enable = NO # disable anonymous user logon
- Anon_umask = 002
- Anon_world_readable_only = NO # downloadable
- Anon_upload_enable = YES # upload allowed
- Anon_mkdir_write_enable = YES # You can create a directory.
- Anon_other_write_enable = YES # It can be modified or deleted.
- Guest_enable = YES # open a virtual user
- Guest_username = vftp # system user corresponding to the FTP virtual user Pam_service_name = vsftpd. vu # PAM Authentication File
- Local_root =/var/www/html # directory automatically switched after login (if this line is not added, the virtual user logs on to the/home/vsftp directory)
Wq is saved and exited.
7. Restart the vsftpd service
- # Service vsftpd restart
8. Solve the problem that apache files cannot be accessed (displaying files without permission)
Add an ftp user (vftp here) to the apache user group, and set the user group to have the write permission:
- # Usermod-a-G apache vftp # Add vftp to User Group apache
- # Chown-R: apache/var/www/html # Set/var/www/html to apache
- # Chmod-R g + rw/var/www/html # Set the/var/www/html permission to allow the user group to read and write
Note: you also need to confirm anon_umask = 002 in vsftpd. conf so that the user group of the newly uploaded file has the write permission.