ProFtpd入門指南
圖-ProFTPD
ProFTPD設(shè)計(jì)目標(biāo)是實(shí)現(xiàn)一個(gè)安全且易于設(shè)定的FTP Server。目前Unix或類Unix平臺(tái)上
FTP Server十分有限,最常使用的恐怕就是wu-ftpd了。雖然wu-ftpd有著極佳的效能同時(shí)也是
一套很好的軟件,然而它卻欠缺了許多Win32平臺(tái)上FTP Server的一些特色,同時(shí)wu-ftpd過(guò)去
也有不少的安全漏洞陸續(xù)被發(fā)現(xiàn)。ProFTPD的原創(chuàng)者本身就曾經(jīng)花非常多的時(shí)間尋找wu-ftpd
的漏洞加以改進(jìn)并且增加許多功能。然而十分不幸的是,他很快地發(fā)現(xiàn)顯然wu-ftpd需要全部
重新的改寫才能補(bǔ)足欠缺的設(shè)定能力以及缺乏的一些功能。ProFTPD不是從其它FTP Server的
既有原始碼修改而產(chǎn)生的,相反的,它是完全獨(dú)立而完整、重新改寫的FTP Server。
ProFTPD的主要包括如下特點(diǎn):
* 單一主設(shè)置文件,包含許多指令以及其支配的組,? 耆際侵憊鄣納瓚āH綣魑歡訟
pache Web Serve的設(shè)置不陌生的話相信一定會(huì)覺(jué)得十分容易操作設(shè)定。
* 每個(gè)目錄都可以定義一個(gè)".ftpaccess"設(shè)置文件,就如同Apache的".htaccess"文件一樣可以設(shè)定
該目錄的存取權(quán)限。
* 可設(shè)定多個(gè)虛擬FTP server,而匿名FTP服務(wù)更是十分容易。
* 可根據(jù)系統(tǒng)的負(fù)載(load)選擇以單獨(dú)運(yùn)作(stand-alone)方式或是由inetd啟動(dòng)。
* 匿名FTP的根目錄不需要特定的目錄結(jié)構(gòu)、系統(tǒng)二進(jìn)制執(zhí)行文件或其它系統(tǒng)文件。
* ProFTPD不執(zhí)行任何外部程序以免造成安全漏洞。
* 具有隱藏目錄或隱藏文件,源自于Unix形式的檔案權(quán)限,或是user/group類型的檔案權(quán)限設(shè)定。
* 能夠以一般使用者在單獨(dú)運(yùn)作(stand-alone)模式下執(zhí)行,以減少某些藉由攻擊方式取得root權(quán)的
可能性。注:此功能與Unix的操作系統(tǒng)有關(guān)。
* 支持系統(tǒng)記錄以及utmp/wtmp。
記錄的方式與wu-ftpd的標(biāo)準(zhǔn)完全兼容,也支持記錄內(nèi)容的延伸格式。
* 支持Shadow&! nbsp;password,包括了帳號(hào)使用期限設(shè)定的功能。
編譯和安裝
Proftpd提供了多種安裝格式,包括源代碼方式、RPM方式、deb方式(debian軟件包)等。本文
主要討論源代碼方式的安裝。
從ftp.proftpd.net下載最新版本的proftpd-1.2.0rc3到Linux服務(wù)器上。然后按照如下步驟
進(jìn)行處理:
- [root@ftpd /]# cp proftpd-1.2.0rc3.tar.gz /usr/src/
- [root@ftpd /]# cd /usr/src
- [root@ftpd src]# tar xvfz proftpd-1.2.0rc3.tar.gz
- [root@ftpd src]# cd proftpd-1.2.0rc3
- [root@pftd proftpd-1.2.0rc3]# ./configure
- [root@pftd proftpd-1.2.0rc3]# make
- [root@pftd proftpd-1.2.0rc3]# make install
到現(xiàn)在為止,你已經(jīng)完成了proftpd的編譯和安裝。并且在/usr/local/etc/目錄下有一個(gè)默
認(rèn)的proftpd配置文件proftpd.conf。
啟動(dòng)測(cè)試
對(duì)于筆者的試驗(yàn)系統(tǒng)RedHat6.2來(lái)說(shuō),需要將該配置文件中:
Group nogrou! p
修改為:
Group nobody
因?yàn)閞edhat系統(tǒng)中nobody用戶屬于nobody組,而不是nogroup組。
若需要將proftpd設(shè)置為系統(tǒng)啟動(dòng)時(shí)自動(dòng)啟動(dòng)則通過(guò)如下命令拷貝啟動(dòng)文件:
- [root@ftpd proftpd-1.2.0rc3]# cp ./contrib/dist/rpm/proftpd.init.d /etc/rc.d
- /init.d/proftpd
然后修改該腳本的可執(zhí)行屬性:
[root@ftpd /]# chmod +x /etc/rc.d/init.d/proftpd
然后編輯/etc/rc.d/init.d/functions:
修改
export PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"
為
export PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin"
注:若將在運(yùn)行./cofigure命令時(shí)通過(guò)--prefix選項(xiàng)指定將proftpd安裝在/usr/sbin目! 錄下
則不需要修改fuctions文件。
然后運(yùn)行命令:
- [root@ftpd rc3.d]# chkconfig --level 35 proftpd on
則下次系統(tǒng)啟動(dòng)以后,proftpd將自動(dòng)啟動(dòng)。
最后,需要確保系統(tǒng)當(dāng)前沒(méi)有ftp服務(wù)器在運(yùn)行:
[root@ftpd /]# netstat -ln
若輸出中不包含
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN
這樣的內(nèi)容則可以直接啟動(dòng)proftpd,否則需要關(guān)閉以前的ftpd服務(wù)器。對(duì)于一般的缺省
Linux安裝來(lái)說(shuō),則需要通過(guò)以下的途徑來(lái)關(guān)閉ftp服務(wù)器:
編輯/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
然后:
[root@ftpd ! /]# ps ax|grep inetd
350 ? S 0:00 inetd
得到inetd的進(jìn)程號(hào) ,重新啟動(dòng)inetd進(jìn)程:
[root@ftpd /]# kill -HUP 350
然后通過(guò)如下命令啟動(dòng)proftpd:
[root@ftpd /]# /etc/rc.d/init.d/proftpd start
這時(shí)候可以通過(guò)如下命令來(lái)測(cè)試proftpd是否正常運(yùn)行:
- C:WINDOWS>ftp 192.168.2.33
- Connected to 192.168.2.33.
- 220 ProFTPD 1.2.0rc3 Server (ProFTPD Default Installation)[ftpd.test.com.cn]
- User (192.168.2.33:(none)): ideal
- Password:
- 230 User ideal logged in.
- ftp>
則現(xiàn)在你就擁有了一個(gè)安全可靠的ftp服務(wù)器。
#p#
FAQ
1、我安裝proftpd以后,出現(xiàn)了問(wèn)題,我如何調(diào)試?
通過(guò)通過(guò)命令! /usr/local/sbin/proftpd -d9 -n啟動(dòng)proftpd來(lái)進(jìn)行調(diào)試,則proftp d就會(huì)將
調(diào)試信息打印到consle上以供調(diào)試之用。
2、為什么我的proftpf啟動(dòng)以后,匿名用戶不能登錄?
查看proftp配置文件/usr/local/etc/proftpd.conf,修改為
(這里/home/ftp可以是任何希望匿名用戶登錄以后的當(dāng)前根目錄,
但是確保要使該目錄允許ftp用戶訪問(wèn)),并且若部分的User指令
指定的用戶為ftp用戶,則需要在配置文件中添加如下命令指示:
RequireValidShell off
3、我如何實(shí)現(xiàn)一個(gè)正常用戶登錄以后將其的訪問(wèn)限定在某個(gè)目錄之下?
可以通過(guò)指令DefaultRoot來(lái)實(shí)現(xiàn)。例如若希望將ftpusers組的用戶限定在自己的home目錄下,則
需要首先創(chuàng)建該組:
/usr/sbin/groupadd ftpusers
然后將用戶ideal加入到該組中:
usrmod -G ftpusers ideal
最后在在proftpd.conf文件中添加如下內(nèi)容:
DefaultRoot ~ ftpusers
也可以限制用戶登錄以后僅僅訪問(wèn)自己主目錄下的一個(gè)子目錄:
Default! Root ~/anoftp ftpusers
當(dāng)然也可以將用戶限制在其他目錄之下,而不是自己的home目錄下:
DefaultRoot /tmp ftpusers
也可以限定一個(gè)用戶組的某些用戶被限制,而其他不作限制:
DefaultRoot ~ ftpusers,!empolyee
這個(gè)指令指示僅僅限制ftpusers組中的不是empolyee組的用戶進(jìn)行限制。
4、我如何使用戶登陸時(shí)不顯示ftp服務(wù)器版本信息,以增強(qiáng)安全性?
在proftpd.conf中添加如下內(nèi)容:
ServerIdent off
則再次登錄時(shí),顯示如下內(nèi)容:
- C:WINDOWS>ftp 192.168.2.33
- Connected to 192.168.2.33.
- 220 ftpd.test.com.cn FTP server ready.
- User (192.168.2.33:(none)):
5、在proftpd環(huán)境下如何設(shè)定虛擬主機(jī)?
可以通過(guò)指令:VirtualHost來(lái)實(shí)現(xiàn),一個(gè)最簡(jiǎn)單的例子:
ServerName "virtual FTP server"
若你僅僅希望通過(guò)匿名訪問(wèn)某個(gè)虛擬主機(jī),則使用如下! 的指令:
Serv erName "virtual FTP server"
DenyAll
User private
Group private
AllowAll
這樣192.168.2.35的這臺(tái)主機(jī)則僅僅允許匿名登錄。
筆者的proftpd.conf配置文件內(nèi)容為:
- # 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 &! quot;test.com.cn FTP Server"
ServerType standalone
DefaultServer on
# Port 21 is the standard FTP port.
Port 21
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
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&! nbsp;limit maximum number of processes per&nb sp;service
- # (such as xinetd)
MaxInstances 30
RequireValidShell off
ServerIdent off
# 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.
User ftp
Group ftp
# 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
DefaultRoot ~ ftpusers
ServerName "virtual FTP server"
DenyAll
User private
Group private
AllowAll
通過(guò)文章的介紹和代碼的分析,我們可以清楚的知道proftpd的相關(guān)知識(shí),希望本文對(duì)大家有所幫助!
【編輯推薦】