CentOS7 +vsftpd+mysql (iii) MySQL virtual user mode

Source: Internet
Author: User

CentOS7 +vsftpd+mysql (iii) MySQL virtual user mode

In the previous article through the text file user list mode of user management of FTP user is very inconvenient, next we use the data inventory method, to achieve user management.

First, install MySQL

[[email protected] vsftpd]# yum install wget-y[[email protected] local]# cd/usr/local/src[[email  Protected] src]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm[[email protected] src ]# RPM-IVH mysql-community-release-el7-5.noarch.rpm[[email protected] src]# yum install mysql-community-server[ [email protected] src]# yum install-y mysql[[email protected] src]# rpm-qa |grep mysqlmysql-community-releas E-el7-5.noarchmysql-community-common-5.6.37-2.el7.x86_64mysql-community-client-5.6.37-2.el7.x86_ 64mysql-community-libs-5.6.37-2.el7.x86_64mysql-community-devel-5.6.37-2.el7.x86_ 64mysql-community-server-5.6.37-2.el7.x86_64[[email protected] src]# Find/-name "MySQL"/etc/logrotate.d/ Mysql/etc/selinux/targeted/active/modules/100/mysql/var/lib/mysql/usr/bin/mysql/usr/lib64/mysql/usr/share/ Mysql/usr/include/mysql/usr/include/mysql/mysql[[email protected] src]# systemctl start mysqld

  Second, set up MySQL and create user database

[[email protected] src]# mysql-uroot-p# no password, direct return mysql> show databases;+--------------------+| Database |+--------------------+| Information_schema | | MySQL | | Performance_schema |+--------------------+3 rows in Set (0.00 sec) mysql> set password for ' root ' @ ' localhost ' =password (' 1234Test., ');mysql> create database Vftpuser; Query OK, 1 row Affected (0.00 sec) mysql> use vftpuser;database changedmysql> CREATE table users (ID in T auto_increment not NULL, name char (a) binary NOT NULL, and password char (in) binary NOT NULL,-&     Gt Primary key (ID); Query OK, 0 rows affected (0.34 sec) mysql> insert into users (Name,password) VALUES (' Showmuftp ', password (' 111111 ')); Q Uery OK, 1 row Affected (0.00 sec) mysql> insert into users (Name,password) VALUES (' Showmuweb ', password (' 222222 ')); Query OK, 1 row affected (0.01 sec) mysql> insert into users (Name,password) VALUES (' Showmuguest ', password ('333333 ')); Query OK, 1 row affected (0.01 sec) mysql> \qbye[[email protected] src]# mysql-uroot-p mysql> use Vftpuser; Reading table information for completion of table and column namesyou can turn off this feature to get a quicker startup W Ith-adatabase changedmysql> SELECT Id,name,password from users;+----+-------------+----------------------------- --------------+| ID | name |  Password |+----+-------------+-------------------------------------------+| 1 | showmuftp |  *FD571203974BA9AFE270FE62151AE967ECA5E0AA | | 2 | Showmuweb |  *a0c1808b1a47cecd5c161fee647f5427f4eb6f98 | | 3 | Showmuguest | *DF2FAF9AD979B357C54A6723638197DDB913E1C8 |+----+-------------+-------------------------------------------+3 Rows in Set (0.00 sec) Mysql> \qbye

Third, installation Pam_mysql-0.7rc1

[[email protected] src]# yum install pam-devel[[email protected] src]# wget https://nchc.dl.sourceforge.net/project/ Pam-mysql/pam-mysql/0.7rc1/pam_mysql-0.7rc1.tar.gz[[email protected] src]# tar-zxvf pam_mysql-0.7rc1.tar.gz  [[ Email protected] src]# CD Pam_mysql-0.7rc1[[email protected] src]# yum install-y make gcc-c++ cmake bison-devel ncurses-d Evel gcc autoconf automake zlib* fiex* libxml*[[email protected] pam_mysql-0.7rc1]#./configure--with-mysql=/usr--with- Pam-mods-dir=/lib64/security/[[email protected] pam_mysql-0.7rc1]# make&&make Install

Iv. setting VSFTPD

[[email protected] security]# vim/etc/pam.d/vsftpd.mysqldbauth required/lib64/security/pam_mysql.so user=root Passwd=1234test., host=localhost db=vsftpd table=users usercolumn=name Passwdcolumn=password crypt=2account required/ Lib64/security/pam_mysql.so user=root passwd=1234test., host=localhost db=vsftpd table=users usercolumn=name Passwdcolumn=password crypt=2[[email protected] pam_mysql-0.7rc1]# vim/etc/vsftpd/vsftpd.conf[[email  Protected] pam_mysql-0.7rc1]# cd/etc/vsftpd[[email protected] vsftpd]# lsftpusers vftpuser_conf vftpusers.txt vs ftpd.conf_2017-10-05 vsftpd.conf.rpmsaveuser_list vftpusers.db vsftpd.conf Vsftpd_conf_migrate.sh[[email prot Ected] vsftpd]# Grep-ev ' (^#\s.*|^#|^$) ' vsftpd.confanonymous_enable=yesanon_mkdir_write_enable=yesanon_root=/www/ Ftp/publocal_root=/www/ftp/publocal_enable=yeswrite_enable=yeslocal_umask=022anon_upload_enable=yesdirmessage_ Enable=yesxferlog_enable=yesconnect_from_port_20=yesxferlog_std_format=yeslIsten=nolisten_ipv6=yespam_service_name=vsftpd.mysqldbuserlist_enable=yestcp_wrappers=yesguest_enable=yesguest _username=vftpuseruser_config_dir=/etc/vsftpd/vftpuser_confallow_writeable_chroot=yes[[email protected] vsftpd]# systemctl Restart vsftpd[[email protected] vsftpd]# systemctl status vsftpd vsftpd.service-vsftpd ftp Dae  Mon loaded:loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset:disabled) active:active (running) Since five 2017-10-06 09:58:26 EDT;  5min ago process:8526 execstart=/usr/sbin/vsftpd/etc/vsftpd/vsftpd.conf (code=exited, status=0/success) Main pid:8527   (VSFTPD) CGroup:/system.slice/vsftpd.service├─8527/usr/sbin/vsftpd/etc/vsftpd/vsftpd.conf├─8548/usr/sbin/  Vsftpd/etc/vsftpd/vsftpd.conf├─8550/usr/sbin/vsftpd/etc/vsftpd/vsftpd.conf├─8552/usr/sbin/vsftpd /ETC/VSFTPD/VSFTPD.CONF└─8555/USR/SBIN/VSFTPD/ETC/VSFTPD/VSFTPD.CONF10 09:58:26 Localhost.localdomain Sy StemD[1]: Starting Vsftpd FTP daemon ... October 09:58:26 localhost.localdomain systemd[1]: Started Vsftpd FTP daemon.

CentOS7 +vsftpd+mysql (iii) MySQL virtual user mode

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.