{"id":5204,"date":"2015-09-22T08:26:00","date_gmt":"2015-09-22T00:26:00","guid":{"rendered":"http:\/\/rmohan.com\/?p=5204"},"modified":"2015-09-22T08:26:00","modified_gmt":"2015-09-22T00:26:00","slug":"centos6-7-use-mysql-under-vsftpd-verification","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=5204","title":{"rendered":"CentOS6.7 use MySQL under vsftpd verification"},"content":{"rendered":"<div><\/div>\n<div><\/div>\n<div>\n<strong>CentOS6.7 use MySQL under vsftpd verification<\/strong><\/div>\n<div><\/div>\n<div><\/div>\n<div><\/div>\n<div>A .MySQL installation and configuration<br \/>\n1. Use the yum install MySQL<br \/>\n[root@db1 ~]# yum -y install mysql mysql-server mysql-devel<\/div>\n<div><\/div>\n<div>2. Start MySQL service and modify the MySQL administrator password<br \/>\n[root@db1 ~]# service mysqld start<\/div>\n<div><\/div>\n<div>[root@db1 ~]#\u00a0 \/usr\/bin\/mysqladmin -u root password &#8216;test123&#8217;<\/div>\n<div><\/div>\n<div>\n3. Create a MySQL database and verify the vsftpd table<\/div>\n<div><\/div>\n<div>\n[root@db1 ~]# mysql -u root -p<\/div>\n<div><\/div>\n<div>mysql&gt; create database vsftpd;<br \/>\nQuery OK, 1 row affected (0.01 sec)<br \/>\nmysql&gt; use vsftpd;<br \/>\nDatabase changed<br \/>\n\/\/ Create a three column list of users, an id for the index, name for the account name, password user password<\/div>\n<div><\/div>\n<div>mysql&gt; create table users ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name CHAR(15) NOT NULL UNIQUE KEY,password CHAR(48) NOT NULL );<br \/>\nQuery OK, 0 rows affected (0.00 sec)<br \/>\n\/\/ Add a web account, the password for the web, and stored encrypted password, the account is to wait for the next use FTP server<br \/>\nmysql&gt;\u00a0 insert into users (name,password) values (&#8216;web&#8217;,password(&#8216;web&#8217;));<br \/>\nQuery OK, 1 row affected (0.00 sec)<\/div>\n<div><\/div>\n<div>4. Create a vsftpd a MySQL database account is used to retrieve vsftpd<br \/>\nmysql&gt; grant select on vsftpd.* to vsftpd@localhost identified by &#8216;vsftpd&#8217;;<br \/>\nQuery OK, 0 rows affected (0.00 sec)<br \/>\nmysql&gt; flush privileges;<br \/>\nQuery OK, 0 rows affected (0.00 sec)<br \/>\n\/\/ Just to make the rights with immediate effect<\/div>\n<div><\/div>\n<div>II. Install and configure the PAM module<br \/>\n1. Install dependent libraries<\/div>\n<div><\/div>\n<div>[root@db1 ~]#\u00a0 yum -y install gcc gcc-c++ make pam pam-devel openssl openssl-devel<\/div>\n<div><\/div>\n<div>2. Download and install pam_mysql<\/div>\n<div><\/div>\n<div>[root@db1 software]#\u00a0 wget http:\/\/downloads.sourceforge.net\/project\/pam-mysql\/pam-mysql\/0.7pre3\/pam_mysql-0.7pre3.tar.gz?r=http%3A%2F%2Fpam-mysql.sourceforge.net%2F&amp;ts=1442878889&amp;use_mirror=iweb<\/div>\n<div><\/div>\n<div>[root@db1 software]# cd pam_mysql-0.7pre3<br \/>\n[root@db1 pam_mysql-0.7pre3]# ls<br \/>\nacinclude.m4\u00a0 ChangeLog\u00a0\u00a0\u00a0\u00a0 config.h.in\u00a0 configure\u00a0\u00a0\u00a0\u00a0 COPYING\u00a0 INSTALL\u00a0\u00a0\u00a0\u00a0 ltmain.sh\u00a0\u00a0\u00a0 Makefile.in\u00a0 mkinstalldirs\u00a0 pam_mysql.c\u00a0\u00a0\u00a0\u00a0 pam_mysql.spec.in\u00a0 README<br \/>\naclocal.m4\u00a0\u00a0\u00a0 config.guess\u00a0 config.sub\u00a0\u00a0 configure.in\u00a0 CREDITS\u00a0 install-sh\u00a0 Makefile.am\u00a0 missing\u00a0\u00a0\u00a0\u00a0\u00a0 NEWS\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 pam_mysql.spec\u00a0 pkg.m4\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 stamp-h.in<br \/>\n[root@db1 pam_mysql-0.7pre3]#<br \/>\n.\/configure &#8211;with-openssl<br \/>\nmake &amp;&amp; make install<\/div>\n<div><\/div>\n<div>\u00a0pam files installed by default to the \/lib directory, if the system is 64-bit system, you need to copy a document to \/ lib64 directory<\/p>\n<p>[root@db1 pam_mysql-0.7pre3]# cp \/lib\/security\/pam_mysql.<br \/>\npam_mysql.la\u00a0 pam_mysql.so<\/p><\/div>\n<div><\/div>\n<div>[root@db1 pam_mysql-0.7pre3]# cp \/lib\/security\/pam_mysql.* \/lib64\/security\/<\/div>\n<div><\/div>\n<div>\nCreate a certificate file<br \/>\n[root@db1 pam_mysql-0.7pre3]# cat \/etc\/pam.d\/ftp.mysql<br \/>\nauth required \/lib64\/security\/pam_mysql.so user=vsftpd passwd=vsftpd host=localhost db=vsftpd table=users<br \/>\nusercolumn=name passwdcolumn=password crypt=2<br \/>\naccount required \/lib64\/security\/pam_mysql.so user=vsftpd passwd=vsftpd host=localhost db=vsftpd table=users<br \/>\nusercolumn=name passwdcolumn=password crypt=2<br \/>\n[root@db1 pam_mysql-0.7pre3]#<br \/>\nNote: This is the second line, can not wrap Also note inside the corresponding Fill in the fields.<br \/>\nSpecial instructions crypt Options<br \/>\ncrypt = 0: plain text password<br \/>\ncrypt = 1: Use crpyt () function (corresponding SQL data in the encrypt (), encrypt () randomly generated salt)<br \/>\ncrypt = 2: Use the MYSQL password () function encryption<br \/>\ncrypt = 3: the way that the use of md5 hash<\/div>\n<div><\/div>\n<div>Installation and set up three vsftpd<br \/>\n1. Use the yum install vsftpd<br \/>\n[root@db1 pam_mysql-0.7pre3]# yum -y install vsftpd<\/div>\n<div><\/div>\n<div>2. Backup vsftpd configuration file<br \/>\ncp \/etc\/vsftpd\/vsftpd.conf \/etc\/vsftpd\/vsftpd.conf_bak<\/div>\n<div><\/div>\n<div>\nvi vsftpd.conf<\/div>\n<div><\/div>\n<div>anonymous_enable=NO<br \/>\npam_service_name=ftp.mysql<\/div>\n<div><\/div>\n<div>And add the following:<\/div>\n<div><\/div>\n<div>virtual_use_local_privs=YES<br \/>\nuser_sub_token=$USER<br \/>\nlocal_root=\/var\/ftp\/$USER<br \/>\nguest_enable=YES<br \/>\nguest_username=vsftpdguest<br \/>\nchroot_local_user=YES<br \/>\nuser_config_dir=\/etc\/vsftpd\/vsftpd_user_conf<\/div>\n<div><\/div>\n<div>\nCreate a vsftpdguest account<br \/>\n[root@db1 pam_mysql-0.7pre3]# useradd -s \/sbin\/nologin -d \/var\/ftp vsftpdguest<br \/>\nuseradd: warning: the home directory already exists.<br \/>\nNot copying any file from skel directory into it.<\/div>\n<div><\/div>\n<div>\n[root@db1 pam_mysql-0.7pre3]#\u00a0 mkdir \/etc\/vsftpd\/vsftpd_user_conf<br \/>\nroot@db1 pam_mysql-0.7pre3]# \/etc\/init.d\/vsftpd restart<br \/>\nShutting down vsftpd:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [FAILED]<br \/>\nStarting vsftpd for vsftpd:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [\u00a0 OK\u00a0 ]<\/div>\n","protected":false},"excerpt":{"rendered":"<p> CentOS6.7 use MySQL under vsftpd verification A .MySQL installation and configuration 1. Use the yum install MySQL [root@db1 ~]# yum -y install mysql mysql-server mysql-devel 2. Start MySQL service and modify the MySQL administrator password [root@db1 ~]# service mysqld start [root@db1 ~]# \/usr\/bin\/mysqladmin -u root password &#8216;test123&#8217; 3. Create a MySQL database and verify [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,14],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5204"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5204"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5204\/revisions"}],"predecessor-version":[{"id":5205,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5204\/revisions\/5205"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}