Copyright 2001 OLS3,本講義僅供教育人員參考,任何引用,請(qǐng)先取得作者的同意.
Email: ols3@www.tnc.edu.tw
網(wǎng)站: http://www.ols3-cgi.com 或 http://www.perl.ms 臥龍小三CGI天堂
或 http://perl.tnc.edu.tw/
注意! 本文件編寫(xiě)時(shí), proftpd 的版本是 1.2.0rc2, 不過(guò), 目前您至少要用 1.2.0rc3 以上的版本才好! 建議用 1.2.2rc1 ! (04/14/2001)
一. Say something ....
雖然,目前,大多數(shù)站臺(tái)的 FTP 服務(wù),以采用 WU-FTPD 伺服器程式架設(shè)者居多,而且WU-FTPD 在效能上,一直有不錯(cuò)的表現(xiàn),程式版本更新的速度也不慢,不過(guò),它卻不是一個(gè)夠安全的系統(tǒng),(我手頭上至少有十?dāng)?shù)程式是用來(lái)攻擊 WU-FTPD 的),過(guò)去以來(lái),它一直有著一段很不名譽(yù)的安全漏史。
因此之故,許多網(wǎng)管人員總是想把 WU-FTPD 換掉.......
如果您想找一個(gè)不錯(cuò)的 FTP 伺服程式來(lái)取代 WU-FTPD,試試 ProFTPD 吧!
ProFTPD 的發(fā)展,一開(kāi)始,便是定位在:成為一個(gè)安全且容易設(shè)定的 FTP 伺服器程式。
雖然目前使用 ProFTPD 的站臺(tái)數(shù)量 ,不比 WU-FTPD 多,但它的風(fēng)格及表現(xiàn),卻深得許多網(wǎng)管人員的喜愛(ài)。
以下是 ProFTPD 的特點(diǎn):
單一設(shè)定檔,設(shè)定風(fēng)格接近 Apache 設(shè)定檔
每一目錄可用 .ftpaccess 來(lái)控制(類(lèi)似 Apache 的 .htaccess)
易於設(shè)定多重虛擬主機(jī)以及匿名FTP
可讓管理人員選擇 standalone 或 inetd 的執(zhí)行方式
匿名FTP不需要額外的目錄結(jié)構(gòu)
原始碼開(kāi)放,沒(méi)有 SITE EXEC 指令,安全性可受監(jiān)控
根據(jù)系統(tǒng)檔案權(quán)限,可隱藏目錄或檔案
以較低權(quán)限的身份來(lái)執(zhí)行,降低萬(wàn)一被攻入的危險(xiǎn)
記錄檔支援 utmp/wtmp,并和 wu-ftpd 相容,記錄格式也可擴(kuò)充
支援 shadow password
二. 開(kāi)始安裝吧!
先移除匿名 FTP
rpm -e anonftp
再移除 WU-FTPD
rpm -e wu-ftpd
* 請(qǐng)放心,您放在 /home/ftp/pub 下的檔案,不會(huì)不見(jiàn)啦!
(除非您是新裝 WU-FTPD 而 /home/ftp/pub 尚未放入任何檔案)
ProFTPD 下載區(qū)
ftp://ftp.tnc.edu.tw/pub/Sysop/FTP
或
http://www.profptd.net
選擇 ProFTPD 的下載版本
共有三種情況,各有二種安裝方式:standalone 或 inetd
a. 若您是 RedHat 6.1 + CLE 0.9 以前
若您打算采用 standalone 的執(zhí)行方式,請(qǐng)抓取 proftpd-core-1.2.0pre10-1CLE.i386.rpm 及 proftpd-standalone-1.2.0pre10-1CLE.i386.rpm
若您打算采用 inetd 的執(zhí)行方式,請(qǐng)抓取 proftpd-core-1.2.0pre10-1CLE.i386.rpm 及 proftpd-inetd-1.2.0pre10-1CLE.i386.rpm
b. 若您是 RedHat 6.2 + CLE 0.9p1-1
若您打算采用 standalone 的執(zhí)行方式,請(qǐng)抓取 proftpd-core-1.2.0rc2-2CLE.i386.rpm 及 proftpd-standalone-1.2.0rc2-2CLE.i386.rpm
若您打算采用 inetd 的執(zhí)行方式,請(qǐng)抓取 proftpd-core-1.2.0rc2-2CLE.i386.rpm 及 proftpd-inetd-1.2.0rc2-2CLE.i386.rpm
c. 若您是 RedHat 英文版
請(qǐng)抓取 proftpd-1.2.0rc2-2.i386.rpm 或 proftpd-1.2.0rc2.tar.gz
安裝 ProFTPD
(1) RedHat 6.1 + CLE 0.9 + standalone執(zhí)行方式
rpm -ivh proftpd-core-1.2.0pre10-1CLE.i386.rpm
(或 rpm -ivh proftpd-core*.rpm)
rpm -ivh proftpd-standalone-1.2.0pre10-1CLE.i386.rpm
(或 rpm -ivh proftpd-standalone*.rpm)
(2) RedHat 6.1 + CLE 0.9 + inetd 執(zhí)行方式
rpm -ivh proftpd-core-1.2.0pre10-1CLE.i386.rpm
(或 rpm -ivh proftpd-core*.rpm)
rpm -ivh proftpd-inetd-1.2.0pre10-1CLE.i386.rpm
(或 rpm -ivh proftpd-inetd*.rpm)
(3) RedHat 6.2 + CLE 0.9p1-1 + standalone執(zhí)行方式
rpm -ivh proftpd-core-1.2.0rc2-2CLE.i386.rpm
(或 rpm -ivh proftpd-core*.rpm)
rpm -ivh proftpd-standalone-1.2.0rc2-2CLE.i386.rpm
(或 rpm -ivh proftpd-standalone*.rpm)
(4) RedHat 6.2 + CLE 0.9p1-1 + inetd 執(zhí)行方式
rpm -ivh proftpd-core-1.2.0rc2-2CLE.i386.rpm
(或 rpm -ivh proftpd-core*.rpm)
rpm -ivh proftpd-inetd-1.2.0rc2-2CLE.i386.rpm
(或 rpm -ivh proftpd-inetd*.rpm)
(5) RedHat 英文版
rpm -ivh proftpd-1.2.0rc2-2.i386.rpm
或
tar xvzf proftpd-1.2.0rc2.tar.gz
cd proftpd-1.2.0rc2
./configure --enable-shadow
make
make install
ProFTPD 設(shè)定檔的位
用 RPM 檔安裝的 ProFTPD 設(shè)定檔在 /etc/proftpd.conf
若您是抓 tar.gz 檔回來(lái)安裝的,則設(shè)定檔在 /usr/local/etc/proftpd.conf
設(shè)定 ProFTPD
以下是 proftpd.conf 的設(shè)定例(采用 standalone):
# This is a basic ProFTPD configuration file (rename it to
# ‘proftpd.conf‘ for actual use. It establishes a single server
# and a single anonymous login. It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.
# ServerName : 設(shè)定您的站臺(tái)名稱(chēng)
ServerName "OLS3.com"# ServerType : 設(shè)定 ProFTPD 的執(zhí)行方式,可以是 standalone 或 inetd
ServerType standalone# DefaultServer 用來(lái)設(shè)定 unknown 的連接是否由預(yù)設(shè)的主機(jī)來(lái)處理
DefaultServer on
# Port 21 is the standard FTP port.
# Port 21 是 FTP 標(biāo)準(zhǔn)的通道
Port 21
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.# 檔案安全濾網(wǎng)值設(shè)為 022
Umask 022
# To prevent DoS attacks, 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. Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd)# 可避免 DoS 攻擊的設(shè)定(只限standalone的執(zhí)行方式)
MaxInstances 30
# Set the user and group that the server normally runs at.# 執(zhí)行時(shí)的身份/組別權(quán)限
User nobody
Group nobody
# Normally, we want files to be overwriteable.
AllowOverwrite on
# A basic anonymous configuration, no upload directories.# 以下是匿名 FTP 的設(shè)定
User ftp
Group ftp
AnonRequirePassword off
RequireValidShell off
# We want clients to be able to login with "anonymous" as well as "ftp"
UserAlias anonymous ftp
# Limit the maximum number of anonymous logins
MaxClients 10
# We want ‘welcome.msg‘ displayed at login, and ‘.message‘ displayed
# in each newly chdired directory.
DisplayLogin welcome.msg
DisplayFirstChdir .message
# Limit WRITE everywhere in the anonymous chroot
DenyAll
修改 /etc/inetd.conf
若您打算采用 standalone 的方式來(lái)執(zhí)行,則,尚需修改 /etc/inetd.conf
將其中的 ftp 設(shè)定關(guān)掉,即:
ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd -l -a
改成
#ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd -l -a
啟動(dòng) ProFTPD
/etc/rc.d/init.d/proftpd start
采用 inetd 執(zhí)行時(shí)的設(shè)定方式 (我喜歡用這種模式,但你不必非得和我一樣)
# This is a basic ProFTPD configuration file (rename it to
# ‘proftpd.conf‘ for actual use. It establishes a single server
# and a single anonymous login. It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.
# ServerName : 設(shè)定您的站臺(tái)名稱(chēng)
ServerName "OLS3.com"# ServerType : 設(shè)定 ProFTPD 的執(zhí)行方式,可以是 standalone 或 inetd# 此處是 inetd
ServerType inetd# DefaultServer 用來(lái)設(shè)定 unknown 的連接是否由預(yù)設(shè)的主機(jī)來(lái)處理
DefaultServer on
# Port 21 is the standard FTP port.
# Port 21 是 FTP 標(biāo)準(zhǔn)的通道
Port 21
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.# 檔案安全濾網(wǎng)值設(shè)為 022
Umask 022
# To prevent DoS attacks, 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. Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd)# 可避免 Dos 攻擊的設(shè)定(只限standalone的執(zhí)行方式)
MaxInstances 30
# Set the user and group that the server normally runs at.# 執(zhí)行時(shí)的身份/組別權(quán)限
User nobody
Group nobody
# Normally, we want files to be overwriteable.
AllowOverwrite on
# A basic anonymous configuration, no upload directories.# 以下是匿名 FTP 的設(shè)定
User ftp
Group ftp
AnonRequirePassword off
RequireValidShell off
# We want clients to be able to login with "anonymous" as well as "ftp"
UserAlias anonymous ftp
# Limit the maximum number of anonymous logins
MaxClients 10
# We want ‘welcome.msg‘ displayed at login, and ‘.message‘ displayed
# in each newly chdired directory.
DisplayLogin welcome.msg
DisplayFirstChdir .message
# Limit WRITE everywhere in the anonymous chroot
DenyAll
若您是采用 inetd 的執(zhí)行方式,則必須修改 /etc/inetd.conf 的設(shè)定:
將
ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd -l -a
改成
#ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd -l -a
ftp stream tcp nowait root /usr/sbin/tcpd in.proftpd
或
#ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd -l -a
ftp stream tcp nowait root /usr/sbin/tcpd proftpd
存檔之後,重新啟動(dòng) inetd :
/etc/rc.d/init.d/inet restart
注意事項(xiàng)
a. 若您想限制 FTP 登入的使用者,使他無(wú)法切換到別人的自家目錄(Home Directory),可在 proftpd.conf 中加上:
DefaultRoot ~
b. 若您發(fā)現(xiàn)使用 WS_FTP 等軟體連上FTP時(shí),無(wú)法改變檔案屬性,可在 proftpd.conf 中加上:
AllowChmod true
(注意: 必須是 rc1 以後的版本才適用, pre10之前不行!)
c. 若您發(fā)現(xiàn)使用匿名ftp登入時(shí)出現(xiàn)錯(cuò)誤,大概是 /home/ftp/pub這個(gè)目錄沒(méi)有開(kāi)設(shè),
或者,忘了在 proftpd.conf 中加上 RequireValidShell off
d. 若您想將匿名 ftp 關(guān)掉,只要將 到 這一段設(shè)定用 # 把它mark起來(lái)或直接刪除即可。
e. 若您是抓 tar.gz 自行編譯, 則必須自行手動(dòng)在 /etc/pam.d/ftp 中加入以下PAM設(shè)定(for RedHat Linux)
(假定 /etc/pam.d/ftp不存在,或其中無(wú)以下設(shè)定的話):
auth required /lib/security/pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed
auth required /lib/security/pam_pwdb.so shadow nullok
account required /lib/security/pam_pwdb.so
session required /lib/security/pam_pwdb.so
f. 其它常見(jiàn)的問(wèn)題,請(qǐng)看 FAQ
g. 各項(xiàng)設(shè)定命令,請(qǐng)參考 List of configuration directives
h. 使用手冊(cè):http://hamster.wibble.org/proftpd/(國(guó)外) or 本站 (線上電子書(shū))
i. 原始站臺(tái):http://www.proftpd.net
絕對(duì)安全性???
當(dāng)然,沒(méi)有一套系統(tǒng)是絕對(duì)安全的,ProFTPD 也不例外,不過(guò),依據(jù)各項(xiàng)私下的測(cè)試,ProFTPD 在這方面確實(shí)比 WU-FTPD 出色。
請(qǐng)您量試試吧?! ^_^