Proftpd + mysql user authentication + quota Disk quota (1) -- Linux general technology-Linux technology and application information. For details, see the following.
Proftpd + mysql user authentication + quota Disk quota (1)
1. Download and install
First download the source code
1) proftpd1.2.7:
Ftp://ftp.proftpd.org/distrib/source/proftpd-1.2.7.tar.bz2
2) mod_quotatab-1.2.4 (1.2.5 version of mod_quotatab is used on the latest 1.2.8rc1)
Http://www.castaglia.org/proftpd/modules/proftpd-mod-quotatab-1.2.4.tar.gz
Assume that mysql has been installed on your machine.
Start compilation and Installation
Decompress the proftpd source code package to a temporary directory:
Localhost proftpd # tar-jxvf proftpd-1.2.7.tar.bz2
Extract mod_quotatab-1.2.4
Localhost proftpd # tar-zxvf proftpd-mod-quotatab-1.2.4.tar.gz
Go to the mod_quotatab directory
Localhost proftpd # cd mod_quotatab
Copy the files in mod_quotatab to the modules directory in proftpd.
Localhost mod_quotatab # cp * ../proftpd-1.2.7/modules
Before running configure, we need to change a file.
Go to the proftpd-1.2.7/contrib directory
Localhost mod_quotatab # cd ../proftpd-1.2.7/contrib
Modify mod_ SQL _mysql.c
Localhost contrib # vi mod_ SQL _mysql.c
Find # include and set it to your actual path. If your mysql is installed in/usr/local/mysql, change it to # include r.
Then execute:
Localhost contrib # cd ..
Localhost proftpd-1.2.7 # cd ..
Localhost proftpd #./configure -- prefix = DIR -- with-modules = mod_ SQL: mod_ SQL _mysql: mod_quotatab: mod_quotatab_ SQL -- with-synchronized des = DIR -- with-libraries = DIR
Three items to be modified:
-- Prefix = DIR: Where do you want to install it?
-- With-Primary des = DIR mysql's primary des directory
-- With-libraries = DIR mysql lib directory
Then execute:
Make
Make install
Complete the installation.
2. configuration process
I will not talk much about basic configuration. There are a lot of articles on the Internet, but I can't find them myself. Here I will mainly introduce how to configure mysql user authentication and disk quota.
1) mysql user authentication Section
Add the following content to proftpd. conf:
# Set MySQL authentication:
# Database connection information. DatabaseName indicates the database name, HostName indicates the host name, # Port indicates the Port number, UserName indicates the UserName used to connect to the database, and Password indicates the Password.
SQLConnectInfo DatabaseName @ HostName: port UserName Password
# Database Authentication Type:
SQLAuthTypes Backend Plaintext
# Specify information about the table used for user authentication. ("FTPUSERS" and "FTPGRPS" are the names of the data tables, which will be created below after a while)
SQLUserInfo FTPUSERS userid passwd uid gid homedir shell
SQLGroupInfo FTPGRPS groupname gid members
# Set to allow users to log on If shell is empty:
RequireValidShell off
# Database Authentication
SQLAuthenticate users groups usersetfast groupsetfast
# If the home directory does not exist, the system creates a directory based on its home item:
SQLHomedirOnDemand on
Create a user table FTPUSERS in this database, which is required:
Use FTP;
Create table FTPUSERS (
Userid text not null,
Passwd text not null,
Uid int not null,
Gid int not null,
Home TEXT,
Shell TEXT
);
This table is required for user authentication. userid and passwd are essential, and userid is the username used for FTP service; passwd is the password of this user; uid is the ID of the System user, that is, the mapped system user; gid is the ID of the system group to which the user belongs; home is the HOME directory of the user; you can specify a shell for this user. Of course, you can create more fields, such as the count used to record the number of user logins, or the date of the date. If you are familiar with the configuration, you can add more features as you like. I will not talk about it here.
If you want to use all the functions, you can add another required table: FTPGRPS, that is, the table for determining the group. Of course, you can also skip it. here we will describe its format:
Create table FTPGRPS (
Pagername text not null,
Gid smallint not null,
Members text not null,
);
In this example, the value of "kgname" indicates the group name, "gid" indicates the system group ID, and "members" indicates the group members. Note: multiple members must be separated by commas (,). spaces are not allowed.
Insert record for an empty table:
Insert into ftpusers (userid, passwd, uid, gid, home, shell)
ValueS ('user1', '000000', '000000', '000000', '/home/FTP/user1 ',');
In this format, you can insert a record for each user.
If you want to apply more features and create a group table, you also need to add records for it. However, you must note that multiple members in the members field must be separated by commas.
Insert into ftpgrps values ('ftpgrppps', 1000, 'ftpusr ');