Application of Proftpd Study Notes

Source: Internet
Author: User

 

Figure-ProFTPD

Today we will talk aboutProftp+ Mysql + quota is the most anticipated application.

1. First, create the corresponding user and user group

Groupadd-g 5500 ftpgroup

Adduser-u 5500-s/bin/false-d/bin/null-c "proftpd user"-g ftpgroup ftpuser

2. operate databases

Mysql-uroot-ppassword

Create database ftpdb

Grant select, update on ftpdb. * to proftpd @ localhost identified by 'Password'

Use ftpdb

Create table 'ftpgroup '(

'Groupname' varchar (16) not null default '',

'Gid' smallint (6) not null default '20140901 ',

'Members 'varchar (16) not null default '',

KEY 'groupname' ('groupname ')

) TYPE = MyISAM COMMENT = 'proftp group table ';

Insert into 'ftpgroup' VALUES ('ftpgroup', 5500, 'ftpuser ');

Create table 'ftpquotalimits '(

'Name' varchar (30) default NULL,

'Quota _ type' enum ('user', 'group', 'class', 'all') not null default 'user ',

'Per _ session' enum ('false', 'true') not null default 'false ',

'Limit _ type' enum ('soft ', 'hard') not null default 'soft ',

'Bytes _ in_avail 'float not null default '0 ',

'Bytes _ out_avail 'float not null default '0 ',

'Bytes _ xfer_avail 'float not null default '0 ',

'Files _ in_avail 'int (10) unsigned not null default '0 ',

'Files _ out_avail 'int (10) unsigned not null default '0 ',

'Files _ xfer_avail 'int (10) unsigned not null default '0'

) TYPE = MyISAM;

Create table 'ftpquotatallies '(

'Name' varchar (30) not null default '',

'Quota _ type' enum ('user', 'group', 'class', 'all') not null default 'user ',

'Bytes _ in_used' float not null default '0 ',

'Bytes _ out_used' float not null default '0 ',

'Bytes _ xfer_used' float not null default '0 ',

'Files _ in_used' int (10) unsigned not null default '0 ',

'Files _ out_used' int (10) unsigned not null default '0 ',

'Files _ xfer_used' int (10) unsigned not null default '0'

) TYPE = MyISAM;

Create table 'ftpuser '(

'Id' int (10) unsigned not null auto_increment,

'Userid' varchar (32) not null default '',

'Passwd' varchar (32) not null default '',

'Uid' smallint (6) not null default '123 ',

'Gid' smallint (6) not null default '20140901 ',

'Homedir' varchar (255) not null default '',

'Shell 'varchar (16) not null default'/sbin/nologin ',

'Count' int (11) not null default '0 ',

'Accessed' datetime not null default '2017-00-00 00:00:00 ',

'Modified' datetime not null default '2017-00-00 00:00:00 ',

Primary key ('id ')

) TYPE = MyISAM COMMENT = 'proftp user table ';

Note that you can enter the user name and password of your database as needed. If you are not familiar with database operations, you can use phpmyadmin.

3. Configure the proftp File

ServerName "Frank's FTP Server" ServerType standalone DefaultServer on

Port 21

Umask 022

MaxInstances 30

MaxLoginAttempts 3

User nobody

Group nobody

MaxHostsPerUser 1 "Sorry, you may not connect more than one time ."

MaxClientsPerUser 2 "Only one such user at a time ."

MaxClientsPerHost 3 "Sorry, you may not connect more than one time ."

RootLogin off

RequireValidShell off

TimeoutStalled 10

MaxClients 10

AllowForeignAddress on

AllowStoreRestart on

ServerIdent off

DefaultRoot ~ Ftpgroup

SQLAuthTypes Backend Plaintext

# Backend indicates that the user authentication method is MySQL database authentication method

# Plaintext indicates the Plaintext authentication method, which is the first method to be used.

SQLAuthenticate users * groups *

# Databasename @ host database_user user_password

SQLConnectInfo ftpdb @ localhost proftpd password

SQLUserInfo ftpuser userid passwd uid gid homedir shell

SQLGroupInfo ftpgroup groupname gid members

SQLHomedirOnDemand on

# If the user's main directory does not exist, the system creates a directory based on the value of the homedir field in the user data table.

# Update count every time user logs in

SQLLog PASS updatecount

SQLNamedQuery updatecount UPDATE "count = count + 1, accessed = now () WHERE userid = '% U'" ftpuser

# Update modified everytime user uploads or deletes a file

SQLLog STOR, DELE modified

SQLNamedQuery modified UPDATE "modified = now () WHERE userid = '% U'" ftpuser

QuotaEngine on

QuotaDirectoryTally on

QuotaDisplayUnits Mb

QuotaShowQuotas on

QuotaLog "/var/log/quota"

SQLNamedQuery get-quota-limit SELECT "name, quota_type, per_session, limit_type, bytes_in_avail, bytes_out_avai

L, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail FROM ftpquotalimits 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_ I

N_used, files_out_used, files_xfer_used FROM ftpquotatallies 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}' "ftpquota

Tallies

SQLNamedQuery insert-quota-tally INSERT "% {0}, % {1}, % {2}, % {3}, % {4}, % {5 }, % {6}, % {7} "ftpquotatallies

QuotaLimitTable SQL:/get-quota-limit

QuotaTallyTable SQL:/get-quota-tally/update-quota-tally/insert-quota-tally

OK, that's easy. Restart the proftp service to use proftp + mysql + quota.

We can add a virtual user to the database ftpuser,

Insert into 'ftpuser' VALUES (1, 'test', 'ftpasswd', 5500,550 0, '/home/test','/sbin/nologin ');

You can directly add a user in phpmyadmin. I believe you don't need to learn how to add it :)

If you want to set quota, you only need to set it in the ftpquotalimits table. The parameters in this table represent:

Quotalimits table

Name:-User Account

Quota type:-user, group, class, all (we use user)

Per_session:-true or false (we use true)

Limit_type:-Hard limit or soft limit (we usually use hard limit)

Bytes_in_avail:-number of bytes allowed for upload

Bytes_out_avail:-number of bytes that can be downloaded

Bytes_xfer_avail:-number of bytes allowed for transmission (including upload/download)

Files_in_avail:-number of files that can be uploaded

Files_out_avail:-number of files that can be downloaded

Files_xfer_avail:-number of files that can be transferred (including upload/download)

To be honest, I used the mysql and quota modules to verify the user and set the disk quota, but I still think it is not perfect, because in this method, the database table does not have the corresponding permission field, therefore, the permissions of the corresponding user must be controlled by the actual user, that is, the uid and gid corresponding to mysql. That day, if the mysql database can also have full control of permissions.

If you think an error may occur during format copying, you may wish to download my configuration file and database table directly.

Through the detailed description of the article, we are sure that everyone knows the application of Proftpd and hope to help everyone!

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.