Configuration
# Install all the packages used in this experimentYum-y Install vsftpd mysql-server mysql-devel pam-devel gcc-c++ make wget# start mysqld serviceService mysqld Start# Initialize the database administrator passwordMysqladmin-uroot Password Redhat# Log in to databaseMysql-uroot-predhat# Create a vftpuser databaseCreate Database Vftpuser;# Enter the Vftpuser databaseUse Vftpuser;# Create tables to store accounts and passwordsCREATE table users (name char ( A),pwdChar A));# Create a test userInsert into users (name,pwd) VALUES (' Test ', Password (' Test '));# For security purposes, create a user that is dedicated to querying the users tableGrant Select on vftpuser.users to [email protected] identified by' Redhat ';# Refresh Permissions TableFlush privileges;# Leave the databaseQuit# Download the mysql-certified PAM module and install itwget http://ncu.dl.sourceforge.net/project/pam-mysql/pam-mysql/0.7rc1/pam_mysql-0.7RC1.tar.gztar Xzf pam_mysql-0.7RC1.tar.gzCDpam_mysql-0.7Rc1./configuremake && make Install# Modify the/etc/pam.d/vsftpd file, comment The original content, add the following contentAuth required/lib/security/pam_mysql.so user=vsqluser passwd=redhat host=localhost db=vftpuser table=users User Column=name passwdcolumn=pwdcrypt=2Account required/lib/security/pam_mysql.so user=vsqluser passwd=redhat host=localhost db=vftpuser table=users User Column=name passwdcolumn=pwdcrypt=2# Create Local users to map virtual usersUseradd- D/var/ftp/vuserdir- S/sbin/nologin VUser# Replace the original contents of the/etc/vsftpd/vsftpd.conf file with the following :Listen=yespam_service_name=vsftpdguest_enable=yesguest_username=vuseranonymous_enable=noanon_world_readable_ Only=nolocal_enable=yes# start VSFTPD serviceService VSFTPD Start
Virtual user access to VSFTPD server via MySQL