如何把 WU-FTPD 換成 ProFTPD?

Copyright 2001 OLS3,本講義僅供教育人員參考,任何引用,請先取得作者的同意.

Email: ols3@www.tnc.edu.tw

網站: http://www.ols3cgi.comhttp://www.perl.ms 臥龍小三CGI天堂

或 http://perl.tnc.edu.tw/

注意! 本文件編寫時, proftpd 的版本是 1.2.0rc2, 不過, 目前您至少要用 1.2.2 以上的版本才好! 建議用 1.2.4 ! (10/26/2001)

一. Say something ....

雖然,目前,大多數站台的 FTP 服務,以採用 WU-FTPD 伺服器程式架設者居多,而且WU-FTPD 在效能上,一直有不錯的表現,程式版本更新的速度也不慢,不過,它卻不是一個夠安全的系統,(我手頭上至少有十數隻程式是用來攻擊 WU-FTPD 的),過去以來,它一直有著一段很不名譽的安全漏史。

因此之故,許多網管人員總是想把 WU-FTPD 換掉.......

如果您想找一個不錯的 FTP 伺服程式來取代 WU-FTPD,試試 ProFTPD 吧!

ProFTPD 的發展,一開始,便是定位在:成為一個安全且容易設定的 FTP 伺服器程式。

雖然目前使用 ProFTPD 的站台數量 ,不比 WU-FTPD 多,但它的風格及表現,卻深得許多網管人員的喜愛。

以下是 ProFTPD 的特點:

二. 開始安裝吧!

  1. 先移除匿名 FTP

    rpm -e anonftp

  2. 再移除 WU-FTPD

    rpm -e wu-ftpd

    * 請放心,您放在 /home/ftp/pub 下的檔案,不會不見啦!
    (除非您是新裝 WU-FTPD 而 /home/ftp/pub 尚未放入任何檔案)

  3. ProFTPD 下載區

    ftp://ftp.tnc.edu.tw/pub/Sysop/FTP



    http://www.profptd.net

  4. 選擇 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

  5. 安裝 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

  6. ProFTPD 設定檔的位罝

    用 RPM 檔安裝的 ProFTPD 設定檔在 /etc/proftpd.conf
    若您是抓 tar.gz 檔回來安裝的,則設定檔在 /usr/local/etc/proftpd.conf

  7. 設定 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. <Directory /*> AllowOverwrite on </Directory> # A basic anonymous configuration, no upload directories.
    # 以下是匿名 FTP 的設定 <Anonymous ~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 <Limit WRITE> DenyAll </Limit> </Anonymous>
  8. 修改 /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


  9. 啟動 ProFTPD

    /etc/rc.d/init.d/proftpd start

  10. 採用 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. <Directory /*> AllowOverwrite on </Directory> # A basic anonymous configuration, no upload directories.
    # 以下是匿名 FTP 的設定 <Anonymous ~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 <Limit WRITE> DenyAll </Limit> </Anonymous>
  11. 若您是採用 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

  12. 注意事項

    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 關掉,只要將<Anonymous ~ftp> 到 </Anonymous>這一段設定用 # 把它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

  13. 絕對安全性???

    當然,沒有一套系統是絕對安全的,ProFTPD 也不例外,不過,依據各項私下的測試,ProFTPD 在這方面確實比 WU-FTPD 出色。

    請您儘量試試吧?! ^_^

希望這份講義對台南縣中小學能有所助益....
Written by OLS3 All right reserved.
01/03/2000 am 3:19

 

 

常見問題與解答:(copy from 台南縣教網中心網管討論區)

FAQ1:
==============================================================
 hsmhsm  :「為什麼設了/bin/false,連ftp都不能登入了??」
為什麼設了/bin/false,連ftp都不能登入了??
以前用6.2時是/bin/nologin不能登入,但是/bin/false可以ftp登入
現在是用7.3,則兩者都不行
是不是有什麼地方該再設定呢??

[2003-04-09 10:27:13 , 163.26.144.192]
--------------------------------------------------------------

	OLS3 回覆  hsmhsm  如下: 
若您是用 proftpd
請參考:http://linux.tnc.edu.tw/techdoc/proftpd.htm
中的設定檔,其中有一句:

RequireValidShell off

把它放入您的 proftpd.conf 中一般區塊(非 Anonymous 區塊)中即可

然後重新啟動 xinetd / or inetd
若 proftpd 為 standalone 則需重新啟動 proftpd

[2003-04-09 10:36:48 , 203.68.102.61]

--------------------------------------------------------------

	hsmhsm 回覆  OLS3  如下: 
ok了!!謝謝您!! *^_^*
建議您有空的話能將這段加入那份教學文件中
這樣我們才不會每次都重覆問同樣的問題來煩大家 :p

==============================================================

$Id: proftpd.htm,v 1.5 2003/04/09 07:12:59 ols3 Exp $