📄 1482.html
字号:
RootLogin on<br>
<br>
如何禁止某个地址访问ftp<br>
比如禁止10.1.1网段的机器访问ftp,可以这么设置<br>
<br>
<Limit LOGIN><br>
Order deny,allow<br>
Deny from 10.1.1.<br>
Allow from all<br>
</Limit><br>
<br>
<br>
虚拟ftp的建立,一般用于一台ftp服务器有好多ip地址,或者ftp用不同的端口,基本设置语法是:<br>
<br>
比如我们要做一个端口是5555的ftp服务器:<br>
<br>
<VirtualHost 210.51.0.124><br>
ServerName "Frank FTP Server"<br>
Port 5555<br>
...<br>
<Directory 目录><br>
...<br>
<Limit 动作><br>
...<br>
</Limit><br>
...<br>
</Directory><br>
</VirtualHost><br>
<br>
<br>
至于虚拟主机中的其他设置跟我以前讲的基本差不多<br>
<br>
上传/下载比率设置,我想用过Serv_U的朋友一定知道这个功能的使用,我们这里让proftp也实现这个功能。<br>
要实现功能注意编译的时候加入ratio模块,否则proftp默认是不支持,假设有个帐户ftp1的ftp目录在/home/kaoyan ,然后我们设置ftp1的上传/下载比率是1:2(即上传1M,就可以下载2M)<br>
<br>
touch /home/kaoyan/ratio.dat<br>
touch /home/kaoyan/ratio.tmp<br>
chmod -R 666 /home/kaoyan<br>
<br>
在proftpd.conf设置如下<br>
<br>
Ratios on<br>
SaveRatios on<br>
RatioFile /home/kaoyan/ratio.dat<br>
RatioTempFile /home/kaoyan/ratio.tmp<br>
<br>
在相应的设置项里添加<br>
<br>
UserRatio ftp1 0 0 2 1000<br>
<br>
#UserRatio "使用者帐户" fileratio filequota byteratio bytequota<br>
# fileratio :以文件为基础的比率,通常不限制,故为 0<br>
# filequota :预设置能下载多少文件,不限制时为 0<br>
# byteratio :就是上传/下载的比例,如果数字为2,表示1:2<br>
# bytequota :预设置能下载多少 KBytes 的文件<br>
#上面设置的就是1:2的比率,默认只允许下载1M的文件<br>
<br>
ok,重启一下,以后ftp1就可以启用上传/下载比率了<br>
<br>
<br>
proftpd学习笔记(四)<br>
<br>
今天我们讲proftp+mysql+quota的应用,我想大家最期待的就是这个了吧<br>
<br>
1.首先我们建立相应的用户和用户组<br>
<br>
groupadd -g 5500 ftpgroup<br>
adduser -u 5500 -s /bin/false -d /bin/null -c "proftpd user" -g ftpgroup ftpuser<br>
<br>
2.操作数据库<br>
<br>
mysql mysql -uroot -ppassword<br>
create database ftpdb<br>
grant select, update on ftpdb.* to proftpd@localhost identified by 'password'<br>
<br>
use ftpdb<br>
<br>
<br>
CREATE TABLE `ftpgroup` (<br>
`groupname` varchar(16) NOT NULL default '',<br>
`gid` smallint(6) NOT NULL default '5500',<br>
`members` varchar(16) NOT NULL default '',<br>
KEY `groupname` (`groupname`)<br>
) TYPE=MyISAM COMMENT='ProFTP group table';<br>
<br>
INSERT INTO `ftpgroup` VALUES ('ftpgroup', 5500, 'ftpuser');<br>
<br>
CREATE TABLE `ftpquotalimits` (<br>
`name` varchar(30) default NULL,<br>
`quota_type` enum('user','group','class','all') NOT NULL default 'user',<br>
`per_session` enum('false','true') NOT NULL default 'false',<br>
`limit_type` enum('soft','hard') NOT NULL default 'soft',<br>
`bytes_in_avail` float NOT NULL default '0',<br>
`bytes_out_avail` float NOT NULL default '0',<br>
`bytes_xfer_avail` float NOT NULL default '0',<br>
`files_in_avail` int(10) unsigned NOT NULL default '0',<br>
`files_out_avail` int(10) unsigned NOT NULL default '0',<br>
`files_xfer_avail` int(10) unsigned NOT NULL default '0'<br>
) TYPE=MyISAM;<br>
<br>
CREATE TABLE `ftpquotatallies` (<br>
`name` varchar(30) NOT NULL default '',<br>
`quota_type` enum('user','group','class','all') NOT NULL default 'user',<br>
`bytes_in_used` float NOT NULL default '0',<br>
`bytes_out_used` float NOT NULL default '0',<br>
`bytes_xfer_used` float NOT NULL default '0',<br>
`files_in_used` int(10) unsigned NOT NULL default '0',<br>
`files_out_used` int(10) unsigned NOT NULL default '0',<br>
`files_xfer_used` int(10) unsigned NOT NULL default '0'<br>
) TYPE=MyISAM;<br>
<br>
CREATE TABLE `ftpuser` (<br>
`id` int(10) unsigned NOT NULL auto_increment,<br>
`userid` varchar(32) NOT NULL default '',<br>
`passwd` varchar(32) NOT NULL default '',<br>
`uid` smallint(6) NOT NULL default '5500',<br>
`gid` smallint(6) NOT NULL default '5500',<br>
`homedir` varchar(255) NOT NULL default '',<br>
`shell` varchar(16) NOT NULL default '/sbin/nologin',<br>
`count` int(11) NOT NULL default '0',<br>
`accessed` datetime NOT NULL default '0000-00-00 00:00:00',<br>
`modified` datetime NOT NULL default '0000-00-00 00:00:00',<br>
PRIMARY KEY (`id`)<br>
) TYPE=MyISAM COMMENT='ProFTP user table' ;<br>
<br>
注意这里大家根据实际情况填写自己数据库的用户名和密码,如果大家对数据库操作不熟悉的话,不妨可以用phpmyadmin来操作。<br>
<br>
3.配置proftp文件<br>
<br>
ServerName "Frank's FTP Server" ServerType standalone DefaultServer on<br>
<br>
Port 21<br>
<br>
Umask 022<br>
<br>
MaxInstances 30<br>
MaxLoginAttempts 3<br>
<br>
User nobody<br>
Group nobody<br>
<br>
MaxHostsPerUser 1 "Sorry, you may not connect more than one time."<br>
MaxClientsPerUser 2 "Only one such user at a time."<br>
MaxClientsPerHost 3 "Sorry, you may not connect more than one time."<br>
<br>
RootLogin off<br>
RequireValidShell off<br>
TimeoutStalled 10<br>
MaxClients 10<br>
AllowForeignAddress on<br>
AllowStoreRestart on<br>
ServerIdent off<br>
DefaultRoot ~ ftpgroup<br>
<br>
SQLAuthTypes Backend Plaintext<br>
#Backend表示用户认证方式为MySQL数据库的认证方式<br>
#Plaintext表示明文认证方式,排在最前面的为最先使用的方式<br>
SQLAuthenticate users* groups*<br>
<br>
# databasename@host database_user user_password<br>
SQLConnectInfo ftpdb@localhost proftpd password<br>
SQLUserInfo ftpuser userid passwd uid gid homedir shell<br>
SQLGroupInfo ftpgroup groupname gid members<br>
SQLHomedirOnDemand on<br>
#如果用户主目录不存在,则系统会根据此用户在用户数据表中的homedir字段的值新建一个目录<br>
# Update count every time user logs in<br>
SQLLog PASS updatecount<br>
SQLNamedQuery updatecount UPDATE "count=count+1,accessed=now() WHERE userid='%u'" ftpuser<br>
# Update modified everytime user uploads or deletes a file<br>
SQLLog STOR,DELE modified<br>
SQLNamedQuery modified UPDATE "modified=now() WHERE userid='%u'" ftpuser<br>
<br>
QuotaEngine on<br>
QuotaDirectoryTally on<br>
QuotaDisplayUnits Mb<br>
QuotaShowQuotas on<br>
QuotaLog "/var/log/quota"<br>
SQLNamedQuery get-quota-limit SELECT "name, quota_type, per_session, limit_type, bytes_in_avail, bytes_out_avai<br>
l, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail FROM ftpquotalimits WHERE name = '%{0}'<br>
AND quota_type = '%{1}'"<br>
<br>
SQLNamedQuery get-quota-tally SELECT "name, quota_type, bytes_in_used, bytes_out_used, bytes_xfer_used, files_i<br>
n_used, files_out_used, files_xfer_used FROM ftpquotatallies WHERE name = '%{0}' AND quota_type = '%{1}'"<br>
<br>
SQLNamedQuery update-quota-tally UPDATE "bytes_in_used = bytes_in_used + %{0}, bytes_out_used = bytes_out_used<br>
+ %{1}, bytes_xfer_used = bytes_xfer_used + %{2}, files_in_used = files_in_used + %{3}, files_out_used = files_<br>
out_used + %{4}, files_xfer_used = files_xfer_used + %{5} WHERE name = '%{6}' AND quota_type = '%{7}'" ftpquota<br>
tallies<br>
<br>
SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}" ftpquotatallies<br>
<br>
QuotaLimitTable sql:/get-quota-limit<br>
QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally<br>
<br>
<br>
ok,就这么简单,重启一下proftp服务就已经能使用proftp+mysql+quota的功能<br>
<br>
我们可以在数据库ftpuser添加一个虚拟用户,<br>
<br>
INSERT INTO `ftpuser` VALUES (1, 'test', 'ftppasswd', 5500, 5500, '/home/test', '/sbin/nologin');<br>
<br>
大家可以在phpmyadmin里直接操作添加一个用户,相信不用我教大家怎么添加吧:)<br>
<br>
如果你想设置quota,只要在ftpquotalimits表里设置一下就行了,这个表里的各个参数分别代表:<br>
<br>
quotalimits表<br>
<br>
name: - 用户帐号<br>
quota type: - user, group, class, all (we use user)<br>
per_session: - true or false (we use true)<br>
limit_type: - 硬限制 or 软限制 (我们一般用硬限制)<br>
bytes_in_avail: - 允许上传的字节数<br>
bytes_out_avail: - 允许下载的字节数<br>
bytes_xfer_avail: - 允许传输的字节数(包括上传/下载)<br>
files_in_avail: - 允许上传的文件数<br>
files_out_avail: - 允许下载的文件数<br>
files_xfer_avail: - 允许传输的文件数(包括上传/下载)<br>
<br>
老实说用mysql和quota模块来验证用户和设置磁盘限额,但我总觉得还是不够完善,因为在这个方法中,数据库表里还没有相应的权限的字段,所以说相应用户的权限还是得用实际得用户即mysql对应得uid和gid来控制权限,那天要是mysql数据库也能完全控制权限就好了。<br>
<br>
大家如果觉得格式拷贝的时候可能会出错的话,不妨直接下载我的配置文件和数据库表<br>
<br>
下载<a href=http://www.5ilinux.com/download/proftpd.conf>proftpd.conf</a><br>
下载<a href=http://www.5ilinux.com/download/ftpdb.sql>ftpdb.sql</a><br>
只是我的数据库表里对应的uid和gid都是5500,大家可根据自己的情况修改:)注意消化哦。<br>
<br>
这个春节一直在学习proftp,终于可以松口气了,希望我的学习笔记可以对一些想学习proftp的朋友有所帮助,请多交流
</FONT><br>
</TD>
</TR>
<TR>
<TD colSpan=2><FONT
class=middlefont></FONT><BR>
<FONT
class=normalfont>全文结束</FONT> </TD>
</TR>
<TR>
<TD background="images/dot.gif" tppabs="http://www.linuxhero.com/docs/images/dot.gif" colSpan=2
height=10></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></TD>
<TD vAlign=top width="20%"
background="images/line.gif" tppabs="http://www.linuxhero.com/docs/images/line.gif" rowSpan=2>
<DIV align=center>
<table class=tableoutline cellspacing=1 cellpadding=4
width="100%" align=center border=0>
<tr class=firstalt>
<td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colspan=2 height=21>
<font class=normalfont><b>所有分类</b></font></td>
</tr>
<tr class=secondalt> <td noWrap width=27%> <font class=normalfont>1:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type1.html" tppabs="http://www.linuxhero.com/docs/type1.html">非技术类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>2:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type2.html" tppabs="http://www.linuxhero.com/docs/type2.html">基础知识</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>3:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type3.html" tppabs="http://www.linuxhero.com/docs/type3.html">指令大全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>4:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type4.html" tppabs="http://www.linuxhero.com/docs/type4.html">shell</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>5:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type5.html" tppabs="http://www.linuxhero.com/docs/type5.html">安装启动</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>6:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type6.html" tppabs="http://www.linuxhero.com/docs/type6.html">xwindow</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>7:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type7.html" tppabs="http://www.linuxhero.com/docs/type7.html">kde</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>8:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type8.html" tppabs="http://www.linuxhero.com/docs/type8.html">gnome</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>9:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type9.html" tppabs="http://www.linuxhero.com/docs/type9.html">输入法类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>10:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type10.html" tppabs="http://www.linuxhero.com/docs/type10.html">美化汉化</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>11:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type11.html" tppabs="http://www.linuxhero.com/docs/type11.html">网络配置</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>12:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type12.html" tppabs="http://www.linuxhero.com/docs/type12.html">存储备份</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>13:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type13.html" tppabs="http://www.linuxhero.com/docs/type13.html">杂项工具</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>14:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type14.html" tppabs="http://www.linuxhero.com/docs/type14.html">编程技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>15:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type15.html" tppabs="http://www.linuxhero.com/docs/type15.html">网络安全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>16:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type16.html" tppabs="http://www.linuxhero.com/docs/type16.html">内核技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>17:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type17.html" tppabs="http://www.linuxhero.com/docs/type17.html">速度优化</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>18:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type18.html" tppabs="http://www.linuxhero.com/docs/type18.html">apache</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>19:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type19.html" tppabs="http://www.linuxhero.com/docs/type19.html">email</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>20:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type20.html" tppabs="http://www.linuxhero.com/docs/type20.html">ftp服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>21:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type21.html" tppabs="http://www.linuxhero.com/docs/type21.html">cvs服务</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>22:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type22.html" tppabs="http://www.linuxhero.com/docs/type22.html">代理服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>23:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type23.html" tppabs="http://www.linuxhero.com/docs/type23.html">samba</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>24:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type24.html" tppabs="http://www.linuxhero.com/docs/type24.html">域名服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>25:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type25.html" tppabs="http://www.linuxhero.com/docs/type25.html">网络过滤</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>26:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type26.html" tppabs="http://www.linuxhero.com/docs/type26.html">其他服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>27:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type27.html" tppabs="http://www.linuxhero.com/docs/type27.html">nfs</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>28:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type28.html" tppabs="http://www.linuxhero.com/docs/type28.html">oracle</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>29:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type29.html" tppabs="http://www.linuxhero.com/docs/type29.html">dhcp</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>30:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type30.html" tppabs="http://www.linuxhero.com/docs/type30.html">mysql</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>31:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type31.html" tppabs="http://www.linuxhero.com/docs/type31.html">php</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>32:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type32.html" tppabs="http://www.linuxhero.com/docs/type32.html">ldap</a></font></td> </tr> </table></td></tr> </table>
</DIV></TD></TR>
<TR vAlign=top>
<TD width="80%">
<DIV align=center><BR>
</DIV>
</TD></TR></TBODY></TABLE></TD></TR>
</TABLE></TD></TR>
</TABLE>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#eeeeee
border=0><TBODY>
<TR>
<TD width="50%">
<P><FONT class=middlefont>版权所有 © 2004 <A
href="mailto:bjchenxu@sina.com">linux知识宝库</A><BR>
违者必究. </FONT></P>
</TD>
<TD width="50%">
<DIV align=right><FONT class=middlefont>Powered by: <A
href="mailto:bjchenxu@sina.com">Linux知识宝库</A> Version 0.9.0 </FONT></DIV>
</TD></TR></TBODY></TABLE>
<CENTER></CENTER></TD></TR>
</TABLE></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -