配置chkconfig腳本
Proftpd的init.d腳本位于Proftpd源代碼安裝包c(diǎn)ontrib/dist/rpm目錄,復(fù)制并改名到/etc/init.d/proftpd即可。
contrib/dist/rpm/proftpd.init.d
注意:源代碼里面的安裝包由于路徑問(wèn)題,無(wú)法執(zhí)行,實(shí)際操作,請(qǐng)修改相應(yīng)部分。
————————/etc/init.d/proftpd———————————
#!/bin/sh
#
# Startupscript for ProFTPD
#
#chkconfig: – 85 15
#description: ProFTPD is an enhanced FTP server with a focus towards
# simplicity, security, and ease ofconfiguration.
# It features a very Apache-likeconfiguration syntax,
# and a highly customizable serverinfrastructure,
# including support for multiple'virtual' FTP servers,
# anonymous FTP, andpermission-based directory visibility.
#processname: proftpd
# config:/usr/local/etc/proftpd.conf
# pidfile:/usr/local/var/proftpd.pid
### BEGININIT INFO
#Provides: proftpd ftpserver
#Required-Start: $local_fs $network $named $remote_fs
#Required-Stop: $local_fs $network $named $remote_fs
#Default-Stop: 0 1 6
#Short-Description: ProFTPd FTP Server
#Description: ProFTPd is an enhanced FTP server with a focus towards
# simplicity, security, and ease ofconfiguration.
# It features a very Apache-likeconfiguration syntax,
# and a highly customizable serverinfrastructure,
# including support for multiple 'virtual'FTP servers,
# anonymous FTP, and permission-baseddirectory visibility.
### ENDINIT INFO
# Sourcefunction library.
./etc/rc.d/init.d/functions
# Sourcenetworking configuration.
./etc/sysconfig/network
# SourceProFTPD configuration.
PROFTPD_OPTIONS=""
if[-f /etc/sysconfig/proftpd ];then
./etc/sysconfig/proftpd
fi
# Checkthat networking is enabled.
[ ${NETWORKING}="no"]&&exit1
# Makesure the binary is present.
##修改sbin/proftpd路徑
[-x /usr/local/sbin/proftpd ]||exit5
##添加下面一行
PATH=$PATH:/usr/local/sbin:/usr/local/bin/
RETVAL=0
prog="proftpd"
start(){
echo -n $"Starting$prog: "
daemon proftpd $PROFTPD_OPTIONS 2>/dev/null
RETVAL=$?
echo
##修改lock/proftpd路徑
[ $RETVAL -eq 0]&& touch /usr/local/var/lock/proftpd
}
stop(){
echo -n $"Shuttingdown $prog: "
killproc proftpd
RETVAL=$?
echo
##修改lock/proftpd路徑
[ $RETVAL -eq 0]&& rm -f /usr/local/var/lock/proftpd
}
# See howwe were called.
case"$1"in
start)
start
;;
stop)
stop
;;
status)
status proftpd
RETVAL=$?
;;
restart)
stop
start
;;
try-restart|condrestart)
##修改lock/proftpd路徑
if[-f /usr/local/var/lock/proftpd ];then
stop
start
fi
;;
reload|force-reload|reread)
echo -n $"Re-reading$prog configuration: "
killproc proftpd -HUP
RETVAL=$?
echo
;;
suspend)
hash ftpshut >/dev/null2>&1
if[ $?=0];then
if[ $# -gt 1 ];then
shift
echo -n "Suspendingwith '$*'"
ftpshut "$@"
RETVAL=$?
else
echo -n "SuspendingNOW"
ftpshut now "Maintenancein progress"
RETVAL=$?
fi
else
echo -n "Noway to suspend"
RETVAL=1
fi
echo
;;
resume)
if[-f /etc/shutmsg ];then
echo -n "Allowingsessions again"
rm -f /etc/shutmsg
else
echo -n "Wasnot suspended"
RETVAL=2
fi
echo
;;
*)
echo -n "Usage:$prog
start|stop|restart|try-restart|reload|status|reread|resume"
hash ftpshut
if[ $?=1];then
echo '}'
else
echo '|suspend}'
echo 'suspendaccepts additional arguments, which are passed to ftpshut(8)'
fi
exit2
esac
exit $RETVAL
然后執(zhí)行命令添加并啟用Proftpd服務(wù)
chkconfig –addproftpd
chkconfigproftpd on
serviceproftpd start
配置日志歸檔
由于Linux本身出于安全考慮,限制用戶(hù)可操作的文件的大小。每個(gè)程序都只能操作大小不超過(guò)2G的文件。使用者可以選擇修改Linux的ulimit信息。增大這個(gè)大小,或取消限制。但是,作者建議,還是乖一點(diǎn),做個(gè)日志歸檔。
proftpd開(kāi)發(fā)者為我們寫(xiě)好了RedHat發(fā)行版中使用的logrotate配置文件,位于contrib/dist/rpm/目錄中,復(fù)制到/etc/logrotate.d/目錄中并改名即可。
contrib/dist/rpm/proftpd.logrotate
同樣,要根據(jù)實(shí)際情況修改路徑信息。修改過(guò)的文件如下
#修改路徑
/usr/local/var/proftpd/log/*.log/var/log/xferlog {
compress
missingok
notifempty
sharedscripts
postrotate
#修改路徑
test -f /usr/local/var/lock/proftpd&& /usr/bin/killall -HUP proftpd || :
endscript
}
配置xinetd (可選)
如果使用xinetd管理proftpd,則需要配置這部分內(nèi)容,否則可以跳過(guò)不看。但話說(shuō)回來(lái),看看也沒(méi)什么壞處,哈哈~
在服務(wù)器負(fù)載不很重的情況下,為了節(jié)省服務(wù)器資源。往往使用xinetd管理proftpd服務(wù)。使用xinetd也能加強(qiáng)服務(wù)器的安全,可以有效阻止DDOS攻擊。
首先修改proftpd.conf文件ServerType部分的standalone為inetd,其次,檢查xinetd是否安裝,沒(méi)安裝就安裝先。
yum install xinetd -y
安裝好xinetd后,復(fù)制配置文件contrib/dist/rpm/xinetd到/etc/xinetd.d/目錄并改名為proftpd。文件內(nèi)容照常修改如下
# default:off
#description: The ProFTPD FTP server
serviceftp
{
flags = REUSE
socket_type = stream
wait =no
user = root
#修改下面一行
server =/usr/local/sbin/in.proftpd
#添加下面一行
server_args =-c /etc/proftpd.conf
#注釋掉下面兩行
#log_on_success += DURATION
#log_on_failure += USERID
nice =10
disable =no
}
最后說(shuō)明一下,使用xinetd管理proftpd時(shí),語(yǔ)言模塊工作不正常,有可能是一個(gè)bug。最好使用standalone模式吧。
配置防火墻
需要開(kāi)放20,21,60000-65535端口。
-A INPUT -m state –state NEW -mmultiport -p tcp –dport 20,21-d 10.1.10.168-j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 60000:65535-d 10.1.10.168-j ACCEPT
結(jié)合網(wǎng)絡(luò)管理員,配置nat地址映射,配置防火墻區(qū)域間策略允許20,21端口通過(guò)。在支持ASPF的防火墻上設(shè)置域間啟用detect ftp,其他防火墻設(shè)置相應(yīng)策略以支持ftp的被動(dòng)傳輸模式。