《proftpd学习笔记(四)》由会员分享,可在线阅读,更多相关《proftpd学习笔记(四)(6页珍藏版)》请在金锄头文库上搜索。
1、1.首先我们建立相应的用户和用户组groupadd -g 5500 ftpgroupadduser -u 5500 -s /bin/false -d /bin/null -c proftpd user -g ftpgroup ftpuser2.操作数据库mysql mysql -uroot ppasswordcreate database ftpdbgrant select, update on ftpdb.* to proftpdlocalhost identified by passworduse ftpdbCREATE TABLE ftpgroup (groupname varchar(
2、16) NOT NULL default ,gid smallint(6) NOT NULL default 5500,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,gro
3、up,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
4、 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_o
5、ut_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_incr
6、ement,userid varchar(32) NOT NULL default ,passwd varchar(32) NOT NULL default ,uid smallint(6) NOT NULL default 5500,gid smallint(6) NOT NULL default 5500,homedir varchar(255) NOT NULL default ,shell varchar(16) NOT NULL default /sbin/nologin,count int(11) NOT NULL default 0,accessed datetime NOT N
7、ULL default 0000-00-00 00:00:00,modified datetime NOT NULL default 0000-00-00 00:00:00,PRIMARY KEY (id) TYPE=MyISAM COMMENT=ProFTP user table ;注意这里大家根据实际情况填写自己数据库的用户名和密码,如果大家对数据库操作不熟悉的话,不妨可以用 phpmyadmin来操作。3.配置 proftp文件ServerName Franks FTP Server ServerType standalone DefaultServer onPort 21Umask 0
8、22MaxInstances 30MaxLoginAttempts 3User nobodyGroup nobodyMaxHostsPerUser 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 offRequireValidShell offTimeoutStalled 10MaxClients 1
9、0AllowForeignAddress onAllowStoreRestart onServerIdent offDefaultRoot ftpgroupSQLAuthTypes Backend Plaintext#Backend表示用户认证方式为 MySQL数据库的认证方式#Plaintext表示明文认证方式,排在最前面的为最先使用的方式SQLAuthenticate users* groups*# databasenamehost database_user user_passwordSQLConnectInfo ftpdblocalhost proftpd passwordSQLUse
10、rInfo ftpuser userid passwd uid gid homedir shellSQLGroupInfo ftpgroup groupname gid membersSQLHomedirOnDemand on#如果用户主目录不存在,则系统会根据此用户在用户数据表中的 homedir字段的值新建一个目录# Update count every time user logs inSQLLog PASS updatecountSQLNamedQuery updatecount UPDATE count=count+1,accessed=now() WHERE userid=%u f
11、tpuser# Update modified everytime user uploads or deletes a fileSQLLog STOR,DELE modifiedSQLNamedQuery modified UPDATE modified=now() WHERE userid=%u ftpuserQuotaEngine onQuotaDirectoryTally onQuotaDisplayUnits MbQuotaShowQuotas onQuotaLog /var/log/quotaSQLNamedQuery get-quota-limit SELECT name, quo
12、ta_type, per_session, limit_type, bytes_in_avail, bytes_out_avail, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail FROM ftpquotalimits WHERE name = %0AND quota_type = %1SQLNamedQuery get-quota-tally SELECT name, quota_type, bytes_in_used, bytes_out_used, bytes_xfer_used, files_in
13、_used, files_out_used, files_xfer_used FROM ftpquotatallies WHERE name = %0 AND quota_type = %1SQLNamedQuery 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 =
14、 files_out_used + %4, files_xfer_used = files_xfer_used + %5 WHERE name = %6 AND quota_type = %7 ftpquotatalliesSQLNamedQuery insert-quota-tally INSERT %0, %1, %2, %3, %4, %5, %6, %7 ftpquotatalliesQuotaLimitTable sql:/get-quota-limitQuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quo
15、ta-tallyok,就这么简单,重启一下 proftp服务就已经能使用 proftpmysqlquota 的功能我们可以在数据库 ftpuser添加一个虚拟用户,INSERT INTO ftpuser VALUES (1, test, ftppasswd, 5500, 5500, /home/test, /sbin/nologin);大家可以在 phpmyadmin里直接操作添加一个用户,相信不用我教大家怎么添加吧:)如果你想设置 quota,只要在 ftpquotalimits表里设置一下就行了,这个表里的各个参数分别代表:quotalimits表 name: - 用户帐号quota type: - user, group, class, all (we use user)per_session: - true or false (we use true)limit_type: - 硬限制 or 软限制 (我们一般用硬限制)bytes_in_avail: - 允许上传的字节数bytes_out_avail: - 允许下载的字节数bytes_xfer_avail: - 允许传输的字节数(包括上传/下载