?? 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 + -