Copyright 2001 OLS3,本講義僅供教育人員參考,任何引用,請先取得作者的同意.
Email: ols3@www.tnc.edu.tw
網站: http://www.ols3-cgi.com 或 http://www.perl.ms 臥龍小三CGI天堂
或 http://perl.tnc.edu.tw/
注意! 本文件編寫時, proftpd 的版本是 1.2.0rc2, 不過, 目前您至少要用 1.2.0rc3 以上的版本才好! 建議用 1.2.2rc1 ! (04/14/2001)
一. Say something ....
雖然,目前,大多數站台的 FTP 服務,以採用 WU-FTPD 伺服器程式架設者居多,而且WU-FTPD 在效能上,一直有不錯的表現,程式版本更新的速度也不慢,不過,它卻不是一個夠安全的系統,(我手頭上至少有十數程式是用來攻擊 WU-FTPD 的),過去以來,它一直有著一段很不名譽的安全漏史。
因此之故,許多網管人員總是想把 WU-FTPD 換掉.......
如果您想找一個不錯的 FTP 伺服程式來取代 WU-FTPD,試試 ProFTPD 吧!
ProFTPD 的發展,一開始,便是定位在:成為一個安全且容易設定的 FTP 伺服器程式。
雖然目前使用 ProFTPD 的站台數量 ,不比 WU-FTPD 多,但它的風格及表現,卻深得許多網管人員的喜愛。
以下是 ProFTPD 的特點:
單一設定檔,設定風格接近 Apache 設定檔
每一目錄可用 .ftpaccess 來控制(類似 Apache 的 .htaccess)
易於設定多重虛擬主機以及匿名FTP
可讓管理人員選擇 standalone 或 inetd 的執行方式
匿名FTP不需要額外的目錄結構
原始碼開放,沒有 SITE EXEC 指令,安全性可受監控
根據系統檔案權限,可隱藏目錄或檔案
以較低權限的身份來執行,降低萬一被攻入的危險
記錄檔支援 utmp/wtmp,並和 wu-ftpd 相容,記錄格式也可擴充
支援 shadow password
二. 開始安裝吧!
先移除匿名 FTP
rpm -e anonftp
再移除 WU-FTPD
rpm -e wu-ftpd
* 請放心,您放在 /home/ftp/pub 下的檔案,不會不見啦!
(除非您是新裝 WU-FTPD 而 /home/ftp/pub 尚未放入任何檔案)
ProFTPD 下載區
ftp://ftp.tnc.edu.tw/pub/Sysop/FTP
或
http://www.profptd.net
選擇 ProFTPD 的下載版本
共有三種情況,各有二種安裝方式:standalone 或 inetd
a. 若您是 RedHat 6.1 + CLE 0.9 以前
若您打算採用 standalone 的執行方式,請抓取 proftpd-core-1.2.0pre10-1CLE.i386.rpm 及 proftpd-standalone-1.2.0pre10-1CLE.i386.rpm
若您打算採用 inetd 的執行方式,請抓取 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 的執行方式,請抓取 proftpd-core-1.2.0rc2-2CLE.i386.rpm 及 proftpd-standalone-1.2.0rc2-2CLE.i386.rpm
若您打算採用 inetd 的執行方式,請抓取 proftpd-core-1.2.0rc2-2CLE.i386.rpm 及 proftpd-inetd-1.2.0rc2-2CLE.i386.rpm
c. 若您是 RedHat 英文版
請抓取 proftpd-1.2.0rc2-2.i386.rpm 或 proftpd-1.2.0rc2.tar.gz
安裝 ProFTPD
(1) RedHat 6.1 + CLE 0.9 + standalone執行方式
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 執行方式
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執行方式
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 執行方式
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 設定檔的位
用 RPM 檔安裝的 ProFTPD 設定檔在 /etc/proftpd.conf
若您是抓 tar.gz 檔回來安裝的,則設定檔在 /usr/local/etc/proftpd.conf
設定 ProFTPD
以下是 proftpd.conf 的設定例(採用 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 : 設定您的站台名稱
ServerName "OLS3.com"# ServerType : 設定 ProFTPD 的執行方式,可以是 standalone 或 inetd
ServerType standalone# DefaultServer 用來設定 unknown 的連接是否由預設的主機來處理
DefaultServer on
# Port 21 is the standard FTP port.
# Port 21 是 FTP 標準的通道
Port 21
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.# 檔案安全濾網值設為 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 攻擊的設定(只限standalone的執行方式)
MaxInstances 30
# Set the user and group that the server normally runs at.# 執行時的身份/組別權限
User nobody
Group nobody
# Normally, we want files to be overwriteable.
AllowOverwrite on
# A basic anonymous configuration, no upload directories.# 以下是匿名 FTP 的設定
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 的方式來執行,則,尚需修改 /etc/inetd.conf
將其中的 ftp 設定關掉,即:
ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd -l -a
改成
#ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd -l -a
啟動 ProFTPD
/etc/rc.d/init.d/proftpd start
採用 inetd 執行時的設定方式 (我喜歡用這種模式,但你不必非得和我一樣)
# 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 : 設定您的站台名稱
ServerName "OLS3.com"# ServerType : 設定 ProFTPD 的執行方式,可以是 standalone 或 inetd# 此處是 inetd
ServerType inetd# DefaultServer 用來設定 unknown 的連接是否由預設的主機來處理
DefaultServer on
# Port 21 is the standard FTP port.
# Port 21 是 FTP 標準的通道
Port 21
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.# 檔案安全濾網值設為 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 攻擊的設定(只限standalone的執行方式)
MaxInstances 30
# Set the user and group that the server normally runs at.# 執行時的身份/組別權限
User nobody
Group nobody
# Normally, we want files to be overwriteable.
AllowOverwrite on
# A basic anonymous configuration, no upload directories.# 以下是匿名 FTP 的設定
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 的執行方式,則必須修改 /etc/inetd.conf 的設定:
將
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
存檔之後,重新啟動 inetd :
/etc/rc.d/init.d/inet restart
注意事項
a. 若您想限制 FTP 登入的使用者,使他無法切換到別人的自家目錄(Home Directory),可在 proftpd.conf 中加上:
DefaultRoot ~
b. 若您發現使用 WS_FTP 等軟體連上FTP時,無法改變檔案屬性,可在 proftpd.conf 中加上:
AllowChmod true
(注意: 必須是 rc1 以後的版本才適用, pre10之前不行!)
c. 若您發現使用匿名ftp登入時出現錯誤,大概是 /home/ftp/pub這個目錄沒有開設,
或者,忘了在 proftpd.conf 中加上 RequireValidShell off
d. 若您想將匿名 ftp 關掉,只要將 到 這一段設定用 # 把它mark起來或直接刪除即可。
e. 若您是抓 tar.gz 自行編譯, 則必須自行手動在 /etc/pam.d/ftp 中加入以下PAM設定(for RedHat Linux)
(假定 /etc/pam.d/ftp不存在,或其中無以下設定的話):
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. 其它常見的問題,請看 FAQ
g. 各項設定命令,請參考 List of configuration directives
h. 使用手冊:http://hamster.wibble.org/proftpd/(國外) or 本站 (線上電子書)
i. 原始站台:http://www.proftpd.net
絕對安全性???
當然,沒有一套系統是絕對安全的,ProFTPD 也不例外,不過,依據各項私下的測試,ProFTPD 在這方面確實比 WU-FTPD 出色。
請您量試試吧?! ^_^
(http://www.fanqiang.com)
進入【UNIX論壇】
|