Use MySQL in Linux to create virtual users in VSFTPD

Source: Internet
Author: User
Tags crypt

Environment: Linux

Prerequisites: Install VSFTPD, MySQL, and PAM_MySQL

1. Add a VSFTPD user
[Root @ xxx] # useradd ftpguest
After a virtual user logs on, the user is located in the/home/vsftpguest directory of vsftpguest. To log on to other directories such as/var/ftp, modify the vsftpguest directory.

2. Create a virtual user database
Mysql> create database ftpuser;
Mysql> use ftpuser;
Mysql> create table users (name char (20), passwd char (20 ));
Mysql> insert into users
-> Values ('ftp ', 'ftp ');
Mysql> quit

3. Set database read permissions for ftpguest
Mysql> grant select on ftpuser. users to vsftpguest @ localhost identified by 'you _ password ';
Mysql> quit

4. Configure VSFTPD to log on with a virtual user
/Etc/vsftpd. conf
Add:
Chroot_local_user = YES
Chroot_list_enable = YES

5. Add authorization For VSFTPD
/Etc/pam. d/vsftpd
Auth required pam_mysql.o user = vsftpguest passwd = you_password host = localhost db = ftpuser table = users usercolumn = name passwdcolumn = passwd crypt = 0
Account required pam_mysql.o user = vsftpguest passwd = you_password host = localhost db = ftpuser table = users usercolumn = name passwdcolumn = passwd crypt = 0

6. Restart VSFTPD.
[Root @ xxx] # service vsftpd restart

Note: When/etc/pam. d/vsftpd is changed, the original content is deleted and only the above content exists.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.