1.proftpd软件下载安装
[root@chenghy ~]# cd /root
[root@chenghy ~]# wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.3.4c.tar.gz
[root@chenghy ~]# tar zxvf proftpd-1.3.4c.tar.gz
[root@chenghy ~]# cd proftpd-1.3.4c
[root@chenghy ~]# ./configure –prefix=/usr/local/proftpd
[root@chenghy ~]# make
[root@chenghy ~]# make install
2.修改proftpd配置文件
[root@chenghy ~]# vim /usr/local/proftpd/etc/proftpd.conf
ServerName “chenghy’s FTP Server”
ServerType standalone # 以独立进程方式运行
DefaultServer on
Port 2100 # FTP端口
Umask 002 # 权限,建议设置为002
UseReverseDNS off # 禁止DNS反查
IdentLookups off # 禁止DNS反查
ServerIdent off # 隐藏软件版本信息
AllowRetrieveRestart on # 下载断点续传
AllowStoreRestart on # 上传断点续传
## 虚拟用户认证信息
AuthOrder mod_auth_file.c # 只允许虚拟用户登陆
AuthUserFile /usr/local/proftpd/etc/ftp.users
AuthGroupFile /usr/local/proftpd/etc/ftp.group
DefaultRoot ~ # 将用户限定在根目录下
PassivePorts 20000 30000 # 被动模式端口段
SystemLog /var/log/proftpd/proftpd.log # 软件日志
TransferLog /var/log/proftpd/proftpd.xfer.log
LogFormat default “%h %u %t %D \”%r\” %s %b” # 日志格式
ExtendedLog /var/log/proftpd/access.log WRITE,READ default # 访问日志
MaxInstances 250 # 允许最大连接
MaxClients 20 # 最大用户数
MaxLoginAttempts 3 # 最大尝试连接次数
TimeoutLogin 30 # 身份验证超时
TimeoutIdle 120 # 发呆超时
TimeoutNoTransfer 300 # 无数据传输超时
User nobody # 定义ftp以哪个用户身份运行
Group nobody # 定义ftp以哪个用户组身份运行
<Directory ~/>
AllowOverwrite on # 允许写入覆盖
<Limit LOGIN CWD RETR READ DIRS> # 设置虚拟用户读权限
AllowALL
</Limit>
<Limit ALL> # 设置omd用户所有权限
Order allow,deny
AllowUser omd
DenyALL
</Limit>
</Directory>
3.添加proftpd虚拟用户和组
[root@chenghy ~]# /usr/local/proftpd/bin/ftpasswd –passwd –name=bsmp –home=/home/omd/file/ –uid=2001 –gid=2000 –shell=/sbin/nologin –file=/usr/local/proftpd/etc/ftp.users
[root@chenghy ~]# /usr/local/proftpd/bin/ftpasswd –passwd –name=omd –home=/home/omd/ –uid=2002 –gid=2000 –shell=/sbin/nologin –file=/usr/local/proftpd/etc/ftp.users
[root@chenghy ~]# /usr/local/proftpd/bin/ftpasswd –group –name=myftp –gid=2000 –member=bsmp –member=omd –file=/usr/local/proftpd/etc/ftp.group
4.将proftpd用户目录设置权限
[root@chenghy ~]# chown -R 2002:2000 /home/omd/
####下面两行用来删除用户和组###########
[root@chenghy ~]# /usr/local/proftpd/bin/ftpasswd –passwd –name=bsmp –delete-user –file=/usr/local/proftpd/etc/ftp.users
[root@chenghy ~]# /usr/local/proftpd/bin/ftpasswd –group –name=myftp –delete-group –file=/usr/local/proftpd/etc/ftp.group
5.将proftpd添加到系统服务
按照网上的资料修改/etc/rc.d/init.d/proftpd文件后发现配置不成功,后来自己修改了一下此文件完成了配置
[root@chenghy ~]# vim /etc/rc.d/init.d/proftpd
#!/bin/sh
# Source function library.
. /etc/rc.d/init.d/functions
RETVAL=0
start() {
echo -n $”Starting proftpd : “
daemon /usr/local/proftpd/sbin/proftpd -c /usr/local/proftpd/etc/proftpd.conf 2>/dev/null
# daemon命令是/etc/rc.d/init.d/functions中自带的
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/proftpd
}
stop() {
echo -n $”Shutting down proftpd : “
killproc proftpd
# killproc命令是/etc/rc.d/init.d/functions中自带的
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/proftpd
}
# See how we were called.
case “$1” in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo “Usage: proftpd { start | stop | restart }”
esac
[root@chenghy ~]# chmod 755 /etc/rc.d/init.d/proftpd
[root@chenghy ~]# chkconfig add proftpd
[root@chenghy ~]# chkconfig –level 35 proftpd on
[root@chenghy ~]# service proftpd start
6.防火墙设置proftpd端口
只允许主动模式访问添加下面的第①、②条,只允许被动模式访问添加下面的②、③条,两种模式都允许添加下面①、②、③条。
[root@chenghy ~]# iptables -A RH-Firewall-1-INPUT -p tcp -m tcp –dport 20 -j ACCEPT
[root@chenghy ~]# iptables -A RH-Firewall-1-INPUT -p tcp -m tcp –dport 2100 -j ACCEPT
[root@chenghy ~]# iptables -A RH-Firewall-1-INPUT -p tcp -m tcp –dport 20000:30000 -j ACCEPT