PrOFTPD1.2.8 + mysql3.23.56 User Certification + Quota Disk Limit V1.0

zhaozj2021-02-16  52

Summary

This article introduces a very good FTP service installation to implement database management and disk limits. As long as you have a slight modification, you can serve as a service platform for the personal leading page server! (The article refers to some online documents, because the time has been written for a long time, I can't help, I hope not to see!) (2003-08-15 10: 39:43)

By brilliant

Proftpd1.2.8 mysql3.23.56 User Certification Quota Disk Limit Installation Environment: RedHat8, Installation Select is a custom, no database and ftp part (because we have to compile it yourself, if you have no problem, you can rpm -qa | grep mysql, then rpm -e mysql * .rpm Uninstall the online about the installation article on PrOFTPD is quite a little, and I use the new Quota disk limit module, MySQL selection 3.23.56. First Download Source Proftpd1.2.8: ftp://ftp.proftpd.org/ Upload FTP: //ftp.proftpd.org/distrib/source/proftpd-1.2.8.tar.gzmod_quotatab-1.2.7http://wwwwwww .castaglia.org / proFTPD / MODULES / PrOFTPD-MOD-quotatab-1.2.7.tar.gz (corresponding PrOFTPD1.2.8 version) mysql3.23.56: http://www.mysql.com/downloads/mysql-3.23. HTML # source Note is to download the source code package (I usually like yourself) all download to the / root directory. 1, install mysql3.23.56 # GroupAdd MySQL # useradd -g mysql mysql # CD / root # tar -zxvf mysql-3.23. 56.Tar.gz # cd mysql-3.23.56 #. / Configure --prefix = / usr / local / mysql # make # make install # scripts / mysql_install_db # chown -r root / usr / local / mysql # chown -r Mysql / usr / local / mysql / var # chgrp -r mysql / usr / local / mysql # cp support-files / my-medium.cnf /etc/my.cnf#/usr/local/mysql/bin/safe_mysqld - User = mysql & 2, install Proftpd to compress the source code of PrOFTPD to a temporary directory: localhost # tar -zxvf proFTPD-1.2.8.TAR.GZ decompressed MOD_QUTATAB-1.2. 7localhost # tar -zxvf proftpd-mod-quotatab-1.2.7.tar.gz into the mod_quotatab directory localhost proftpd # cd mod_quotatab mod_quotatab copy the file to the modules directory proftpd localhost mod_quotatab # cp * ../proftpd-1.2 .8 / modules Before starting configure, we must first change a file into the proDDPD-1.2.8 / contrib to localhost mod_quotatab # cd ../proftpd-1.2.8/contrib modified mod_sql_mysql.c

LocalHost Contrib # vi mod_sql_mysql.c

Find #include #include

Take him to your actual path

If your MySQL is installed under / usr / local / mysql, just like me, change it to #include then

Localhost Contrib # CD ..

LocalhostproftPD-1.2.7 #. / configure --prefix = DIR --with-modules = mod_sql: mod_sql_mysql: mod_quotatab: mod_quotatab_sql --with-incrudes = DIR --WITH-LIBRARIES = DIR

Three places that need to be modified

--prefix = DIR Where are you going to install?

--with-incrudes = DIR mysql's incrudes directory

--with-libraries = DIR mysql LIB directory

then

Make

Make Install Complete the installation

3. Configure ProftPd.conf Next, enter your installed proFTPD directory, modify the ETC / proFTpd.conf file Start configuration Basic configuration explanation: example: proFTpd.confservername "Hrbeu's FTP Server" # Service Name Servertype Standalone #f server startup DefaultServer on # port 21 is the standard FTP port.Port 21 # uses port # Umask 022 is a good standard umask to prevent new dirs and files # from being group and world writable.Umask 022 # limit the user in his owner directoryDefaultRoot ~ # Limiting users can only enter other directories in their own directory #put the proft log files in /var/ftp.syslogsystemlog /data/ftp.syslogsystemLog /Data/ftp.syslog #proftpd system log storage #TRANSFERLOG Log Filestransferlog / data / logs / ftp.transferlog # transmission log storage places #set the maxtimes user attempts timesMaxLoginAttempts when login fails, try landing number 30 # #setup the RestartAllowRetrieveRestart on # setup the download and upload speed # TransferRate [kilobytes-per- Sec [: 100]] # 1.2.8 Rate limit #setup the disk quotaquotadirectoryTALLY ON # Quota B "|" KB "|" MB "|" GB "#setup the disk quota # QuotadirectoryTally on # Quota B" | " KB "|" MB "|" GB "quotadisplayunits kbquotaEngine ONQUOTALOG /DATA/LOGS/Quota.logquotashowquotas on # we PU T ot mod_sql directives in a

Block so they'll

# inherited by the

Block Below, and any other

# Blocks We May Want To Add. for a Simple Server these Don't need

# be in a

Block but it't hurt anything.

# Specify Our connection information. Both mod_sql_mysql and

# MOD_SQL_POSTGRES USE The Same Format, Other Backends May Specify A

# Different Format for the first argument to sqlconnectinfo. by Not

# Specifying a foodh argument, we're defaulting to 'peers'

# Connections - a connection is master to the database at the start of

# The session and closed at the end. this sale be fine for most

# situations.

# SQLCONNECTINFO DBNAME @ Host: Port Username Password

SqlConnectinfo FTP @ localhost: 3306 WGH 58648217

# Specify Our Authentication Schemes. Assuming We're Using

# MOD_SQL_MYSQL, Here We're Saying 'First Try to Authenticate Using

# MySQL's Password Scheme, Then Try to Authenticate The User's

# Password as plaintext '. Note That' plaintext 'Isn't a smart way to

# Store Passwords Unless Well Secured.

SQLAUTHTYPES BACKEND PLAINTEXT

# Specify The Table and Fields for User Information. If you've

# created the database as it specifies in 'readme.mod_sql', you don't

#need to have this Directive At All Unless Not to To To To To To To To To, IVE ELECTED NOT

# Create Some Fields. in this case we're telling mod_sql to look in

# Table 'Users' for the Fields 'UserName', 'Password', 'Uid', And

# 'gid'. The 'homedir' and 'shell' Fields Are Specified As 'Null' -

# this will be explained Below.

# SQLUSERINFO USERS Username Password Uid Gid Null NULL

SQLUSERINFO FTPUSERS USERID Passwd Uid Gid Home Shell

SqlgroupInfo ftpgrps groupname Gid Members

# Here We Tell Mod_sql That Every User It Authenticates Should Have

# The Same Home Directory. a Much More Common Option Would Be To # Specify A Homedir in the Database and Leave this Directive Out. Note

# That this Directive Is Necessary in this case Because We Specified

# The HomeDir Field as 'Null', Above. MOD_SQL Needs To Get Homedir

# Information from * Somewhere *, OtherWise It Will Not Allow Access.

# SqldefaultHomedir "/ TMP"

# This is not a mod_sql specific Directive, But it's here Because

# The way we specified 'SQLUSERINFO', ABOVE. by setting this to

# 'OFF', We're Telling Protepd to Allow Users to Connect Even IF WE

# Have no (or bad) shell information for them. Since We Specified the

# Shell Field As 'Null', Above, We Need To Tell Proftpd To Allow To

# Uses in Even wegh their shell doesn't exist.

Requirevalidshell Off

# Here We Tell MOD_SQL HOW TO GET OUT GROUP INFORMATION.

# this commented out, we're telling mod_sql to go ahead and use the

# Defaults for the Tablename and all the field names.

# SQLGroupInfo Groups Groupname Gid Members

# For small suites, The Following Directive Will Speed ​​Up Queries AT

# The cost of some memory. Larger Sites Should Read The Complete

# Description of the 'sqlauthenticate' Directive; There Are Options

# Here That Control The Use of Potentially Expensive Database

# queries. Note: THESE ARGUMENTS to 'SQLAUTHORITATIVE' LIMIT The WAY

# You can structure your group table. Check the readme for more

# ion system.

SQLAUTHENTICATE USERS

# Finally, Some Example Logging Directives. If you have an integer

# Field named 'Count' in your users Table, these Directives Will

.

# SQLNAMEDQUERY GETCOUNT SELECT "Count, Userid from users where userid = '% u'"

# SQLNAMEDQUERY UpdateCount Update "Count = Count 1 Where userid = '% u'" Users "

# SQLSHOWINFO Pass "230" "You'VE logged on% {getcount} Times,% U"

# SQLLOG Pass UpdateCount

Sqlhomedirondemand on

# ... sql ...............

SQLNamedQuery get-quota-limit SELECT "name, quota_type, per_session, limit_type, bytes_in_avail, bytes_out_avail, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail FROM quotalimits WHERE name = '% {0}' AND quota_type = '% {1}'"

SQLNamedQuery get-quota-tally SELECT "name, quota_type, bytes_in_used, bytes_out_used, bytes_xfer_used, files_in_used, files_out_used, files_xfer_used FROM quotatallies WHERE name = '% {0}' AND quota_type = '% {1}'"

SQLNamedQuery update-quota-tally UPDATE "bytes_in_used = bytes_in_used % {0}, bytes_out_used = bytes_out_used % {1}, bytes_xfer_used = bytes_xfer_used % {2}, files_in_used = files_in_used % {3}, files_out_used = files_out_used % { 4}, files_xfer_used = files_xfer_used % {5} where name = '% {6}' and quota_type = '% {7}' "quotatallies

SqlnamedQuery INSERT-quota-Tally Insert "% {0},% {1},% {2},% {3},% {4},% {5},% {6},% {7}" quotatallies

QuotalimitTable SQL: / GET-Quota-Limit

QuotatallyTable SQL: / GET-quota-Tally / update-quota-tally / insert-quota-tally

# close ou

BLOCK.

#Ghild floor settings

# To prevent dos attics, set the maximum number of child processes

# To 30. if you need to allow more than 30 Concurrent Connections # at ONCE, SIMPLY INCREASE THIS VALUE. NOT THAT THIS ONLY WORKS

# in Standalone Mode, in inetd Mode You Should Use An inetd Server

# That allows you to limited maximum number of processes per service

# (SUCH AS XINETD)

MaxInstances 30

# Set the normal user and group permissions for the server.

User FTPUSR

Group FTPGRP

# NORMALLY, WE WANT FILES to Be overwriteable.

AllowoverWrite on

# A Basic Anonymous Configuration, No Upload Directories. If you

# Don't want to support anonymous access, Simply Remove this

#

...

BLOCK.

User FTP

Group FTP

# W w c t "anonymous" AS Well AS "ftp"

Useralias anonymous ftp

# Ivit the maximum number of anonymous logins

MaxClients 100

# We want 'welcome.msg' displayed at login, and '.Message' Displayed

# in Each Newly Chdired Directory.

DisplayLogin Welcome.msg

DisplayFirstchdir .Message

# Ivit write everywhere in the anonymous chroot

Denyall

4, MySQL user authentication section

Add the following contents in PrOFTPD.conf to set the information of MySQL authentication: # DatabaseName is the database name, Hostname is the host name, # port is the port number, and username is the username where the database is connected, and Password is a password. SQLCONNECTINFO FTP @ localhost: 3306 FTPUSER FTPPASSWD # Database Certified Type: SQLAUTHTYPES BACKEND PLAINTEXT # Specifies information about the user authentication table. ( "FTPUSERS" and "FTPGRPS" is the data table name, but later on in the following establishment) SQLUserInfo FTPUSERS userid passwd uid gid homedir shellSQLGroupInfo FTPGRPS groupname gid members # settings allow users to log on if the shell is empty: Identification RequireValidShell off # database SQLAUTHENTICATEERS Groups UserSetFast GroupSetFast # If the Home directory does not exist, the system will create a new directory based on its Home item: SQLHomedirondemand On then create a user table FTPUsers in this database, this table is required: use ftp; create table ftpusers (Userid text not null, posswd text not null, uid int not null, gid int not null, home text, shell text); this form is required for user authentication, where userid, passwd is essential, UserId is Use the username of the FTP service; Passwd refers to this user's password; UID is the ID of the system user, which is the mappled system user; GID is the ID of the system group; Home is the Home directory; shell Specify the corresponding shell for the user. Of course, you can build more fields, such as counts used to log in user login, or Date's Date, if you are familiar with the configuration, you can add more features based on your own like. There are not many talks here. 3, if you want all the features, you can also add another table: ftpgrps, that is, determine the form of the group, or not, here you speak: create Table FTPGRPS (Grpname Text Not Null, GID Smallint Not Null, Members Text Not Null,); where GrpName is the name of the group, GID is the ID of the system group, and Members is a member of the group. Note: Multi-member, they must be separated by commas with commas and cannot use spaces. 4, insert records for empty form: Insert Into ftpusers (userid, passwd, uid, gid, home, shell) Values ​​('USER1', '999999,' 1000 ',' 1000 ',' / Home / FTP / USER1 ' , ''); Press this format you can insert this to add a record. If you want to apply to more features, and create a group's form, you have to add a record, but you must pay attention to multiple members in the field of Members must be separated by commas.

INSERT INTO FTPGRPS VALUES ('fTPGRPS', 1000, 'ftpusr'); four, establish a corresponding system user for FTP users. In this example, only the entire FTP service only provides an effective system user FTPUSR and group ftpgrp, of course, you can also set multiple system users. But for security considerations, I only set one, use him to launch FTP Daemon and map all FTP users over this user.

First establish an FTPGRP group: GroupAdd -g 1000 -r ftpgrp Established FTPUSR User: AddUser -u 1000 -G 1000 -D / Home / FTP -S / BIN / BASH -R FTPUSR Create Home to FTPUSR, put all FTP User Activity Space Put in this directory: mkdir / home / ftpchown ftpusr / home / ftpchgrp ftpgrp / home / ftp to this MySQL certification section even if the basic configuration is basically configured, the disk limit section is first, or edit the PrOFTPD file # disk limited part quotadirectoryTALLY ON # Disk Limit Unit B "|" KB "|" MB "|" GB "quotadisplayunits" kB "quotaengine on # disk limit log record quotalog" Your Log Path "" opens disk limit information, after logging in to the FTP account, use after the command "quote SITE qUOTA" display the current user's disk quota QuotaShowQuotas on # the following is the SQL call statement, without modification directly copy the past SQLNamedQuery get-quota-limit SELECT "name, quota_type, per_session, limit_type, bytes_in_avail, / bytes_out_avail, bytes_xfer_avail , files_in_avail, files_out_avail, files_xfer_avail FROM quotalimits / WHERE name = '% {0}' AND quota_type = '% {1}' "SQLNamedQuery get-quota-tally SELECT" name, quota_type, bytes_in_used, bytes_out_used, / bytes_xfer_used, files_in_used, files_out_used Files_xfer_used from quotatallies / where name = '% {0}' and quota_type = '% {1}' "sqlnamedquery update-quota-Tally update" bytes_in_used = bytes_in_used % {0}, / bytes_out_used = bytes_out_used % {1}, bytes_xfer_used = bytes_xfer_used % {2}, / files_in_used = files_in_used % {3}, files_out_used = files_out_used % {4}, / files_xfer_used = files_xfer_used % { 5} / where name = '% {6}' and quota_type = '% {7}' "quotatalliessqlnamedquery insert-quota-Tally Insert"% {0},% {1},% {2},% {3}, % {4},% {5},% {6},% {7} "

quotatalliesQuotaLimitTable sql: / get-quota-limitQuotaTallyTable sql: / get-quota-tally / update-quota-tally / insert-quota-tally and create mysql data table CREATE TABLE quotalimits (name VARCHAR (30), quota_type ENUM ( "user" , "Group", "class", "all") Not null, Per_Session Enum ("False", "True") Not NULL, LIMIT_TYPE ENUM ("Soft", "HARD") Not null, bytes_in_avail float not null, bytes_out_avail FLOAT NOT NULL, bytes_xfer_avail FLOAT NOT NULL, files_in_avail INT UNSIGNED NOT NULL, files_out_avail INT UNSIGNED NOT NULL, files_xfer_avail INT UNSIGNED NOT NULL); CREATE TABLE quotatallies (name VARCHAR (30) NOT NULL, quota_type ENUM ( "user", "group" , "class", "all") NOT NULL, bytes_in_used FLOAT NOT NULL, bytes_out_used FLOAT NOT NULL, bytes_xfer_used FLOAT NOT NULL, files_in_used INT UNSIGNED NOT NULL, files_out_used INT UNSIGNED NOT NULL, files_xfer_used INT UNSIGNED NOT NULL); quotatallies table does not require Make changes, it records the current disk usage of the user, automatically records some fields in the quotalimits table. Identification quota_type disk quota. Maximum number of bytes (uploaded and download traffic) files_Avail's number of files_out_avails can download files from the server Files_xfer_avail to start using disk limit (upload and download) from the total number of file_xfer_avail, the total number of file_xfer_avails (upload and download), we must Give 10M space to 10M, up to 500 files can be uploaded to the server, and the file transfer traffic is 20m, and only 10 files can only be transmitted.

Just insert in the MYSQL INSERT INTO `quotalimits` (` name`, `quota_type`,` per_session`, `limit_type`,` bytes_in_avail`, `bytes_out_avail`,` bytes_xfer_avail`, `files_in_avail`,` files_out_avail`, `files_xfer_avail` VALUES ('USER1', 'User', 'False', 'Soft', '10240000', '0', '2048000', '500', '0', '10'); it is possible, no need The set part can now run Proftpd, log in to user1, use quote site quota, use Quote Site Quota's disk usage FTP> Quote Site Quota200-The Current Quota for this session area: name : user1Quota Type: UserPer Session: FalseLimit Type: SoftUploaded Kb: 0.00 / 10000.00Downloaded Kb: unlimitedTransferred Kb: 0.00 / 2000.00Uploaded files: 0 / 500Downloaded files: unlimitedTransferred files: 0/10200 Please contact root @ localhost if these entries are inaccurateOK, Installation Attachment: Start and close Proftpd #! / Bin / sh # proFTPD filesftpd_bin = / usr / local / proFTPD / SBIN / PROFTPDFTPD_CONF = / usr / local / proFTPD / etc / proFTPIDFIDFILE = / usr / local / proFTPD / var /proftpd.pid# if pidfile exists, does it points? ing [-f $ pidfile] ;1npid = `cat $ Pidfile`fiif [! -X $ ftpd_bin]; Thenecho "$ 0: $ ftpd_bin: cannot Execute" EXIT 1FICASE $ 1 Instart) IF [$ PID "]; Thenecho" $ 0: Proftpd [PID $ PID] Already Running "EXITFIIF [-r $ ftpd_conf]; Thenecho "Starting Proftpd ..." $ ftpd_bin -c $ ftpd_confelseecho "$ 0: canNot Start Proftpd - $ ftpd_conf missing" fi ;; stop) IF [-n "$ pid"]; thenecho " Stopping Proftpd ... "Kill -Term $ PIDELSEECHO" $ 0: Proftpd Not Running "EXIT 1FI ;; Restart) IF [-n" $ PID "];

转载请注明原文地址:https://www.9cbs.com/read-22118.html

New Post(0)