目的:
安装配置一个proftpd,达到以下要求
1 不允许匿名访问。
2 开放一个帐号,只有在upload目录有上传权限,可以续传,不能改名和删除。
操作:
0 切换到root帐户
su root //输入root的密码。
1 下载proftpd
地址:www.proftpd.org。这里我们下载了1.2.9版本
#wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.2.9.tar.gz
2 安装proftpd
切换到下载目录,假设为/tmp/proftpd,然后
tar zxvf proftpd-1.2.9.tar.gz //解压
cd proftpd-1.2.9
./configure --prefix=/var/proftpd --sysconfdir=/etc //设置安装目录/var/proftpd,配置文件目录/etc
make
make install
3 新建ftp专用帐号
就是上面目的中提到的那个专用帐号,这里以skate/skate(u/p)为例。
groupadd skate
useradd skate -g skate -d /var/ftp -s /sbin/nologin //设置/var/ftp目录为ftp的目录
passwd skate //设置skate用户的密码
mkdir /var/ftp/upload
chown skate.skate /var/ftp/upload //设置upload目录skate用户可写
4 设置proftpd
proftpd的配置文件就一个,就是/etc/proftpd.conf
vi /etc/proftpd.conf //打开proftpd.conf
- ####具体配置如下######
- ServerName "Test ftp server..."
- ServerType standalone
- DefaultServer on
- #端口
- Port 21
- Umask 022
- #最大线程数
- MaxInstances 30
- User skate
- Group skate
- #DNS反查
- UseReverseDNS off
- IdentLookups off
- #最大尝试连接次数
- MaxLoginAttempts 3
- #每用户线程
- MaxClientsPerHost 2
- #最大用户数
- MaxClients 20
- DirFakeUser On skate
- DirFakeGroup On skate
- DeferWelcome On
- #日志文件位置
- SystemLog /var/log/proftpd.log
- ServerIdent off
- #限制skate组的skate用户登录时不能切换到其他目录(只能呆在他的home目录)
- DefaultRoot ~ skate,skate
- #设置只允许192.168.0的用户登录
- #
- #Order allow,deny
- #Allow from 192.168.0.
- #Deny from all
- #
- #设置只允许skate用户登录,否则系统用户也可以登录ftp
- #
- #Order allow,deny
- #DenyUser !skate
- #
- #开起全盘的写权限
- AllowOverwrite on
- AllowStoreRestart on
- #允许FXP
- # AllowForeignAddress on
- AllowAll
- #设置skate用户在upload的限制
- #DELE删除权限
- #RNFR RNTO重命名权限
- #RMD XRMD移动目录权限
- DenyUser skate
- #####结束######
5 启动服务
编辑一个启动脚本(这个是proftpd自带的,做了一点小修改)
vi /etc/rc.d/init.d/proftpd[/code:1:0258b10472]
- #####脚本内容开始########
- #!/bin/sh
- #
- # Startup script for ProFTPD
- #
- # chkconfig: 345 85 15
- # description: ProFTPD is an enhanced FTP server with \
- # a focus toward simplicity, security, and ease of configuration. \
- # It features a very Apache-like configuration syntax, \
- # and a highly customizable server infrastructure, \
- # including support for multiple&np'''vira''' FTP servers, \
- # anonymous FTP, and permission-based directory visibility.
- # processname: proftpd
- # config: /etc/proftpd.conf
- #
- # By: Osman Elliyasa
- # $Id: proftpd.init.d,v 1.7 2002/12/07 21:50:27 jwm Exp $
- # Source function library.
- . /etc/rc.d/init.d/functions
- if [ -f /etc/sysconfig/proftpd ]; then
- . /etc/sysconfig/proftpd
- fi
PATH="$PATH:/usr/local/sbin:/var/proftpd/bin:/var/proftpd/sbin"
- # See how we were called.
- case "$1" in
- start)
- echo -n "Starting proftpd: "
- daemon proftpd $OPTIONS
- echo
- touch /var/lock/subsys/proftpd
- ;;
- stop)
- echo -n "Shutting down proftpd: "
- killproc proftpd
- echo
- rm -f /var/lock/subsys/proftpd
- ;;
- status)
- status proftpd
- ;;
- restart)
- $0 stop
- $0 start
- ;;
- reread)
- echo -n "Re-reading proftpd config: "
- killproc proftpd -HUP
- echo
- ;;
- suspend)
- hash ftpshut >/dev/null 2>&1
- if [ $? = 0 ]; then
- if [ $# -gt 1 ]; then
- shift
- echo -n "Suspending with&s;''*''' "
- ftpshut $*
- else
- echo -n "Suspending NOW "
- ftpshut now "Maintanance in progress"
- fi
- else
- echo -n "No way to suspend "
- fi
- echo
- ;;
- resume)
- if [ -f /etc/shutmsg ]; then
- echo -n "Allowing sessions again "
- rm -f /etc/shutmsg
- else
- echo -n "Was not suspended "
- fi
- echo
- ;;
- *)
- echo -n "Usage: $0 {start|stop|restart|status|reread|resume"
- hash ftpshut
- if [ $? = 1 ]; then
- echo&s;'''&2;'''
- else
- echo&s;'''|suspend&2;'''
- echo&s;'''suspend accepts additional arguments which are passed to ftpshut(84;'''
- fi
- exit 1
- esac
- if [ $# -gt 1 ]; then
- shift
- $0 $*
- fi
- exit 0
- #######脚本结束#########
修改权限,然后添加到系统服务并启动
chmod +x /etc/rc.d/init.d/proftpd
chkconfig --add proftpd
service proftpd start[/code:1:0258b10472]
以后可以用service proftpd restart来重起proftpd。
6 一点体会
看proftpd的文档翻译过的一句话:Finally, a special command is allowed which can be used to control login access: LOGIN Connection or login to
the server. Applying a
effect, and is ignored, when used in a context other than server config,
is meaningless).
翻译下:最后,有一个用来限制登陆的特殊命令,就是LOGIN。在
或者
proftpd感觉还是比vsftp功能配置上好用一点,主要掌握好
proftpd文档地址http://www.proftpd.org/docs/。[/code]
修改了好几次了,之前有些笔误和忘记写的地方,有什么问题大家提出来,我会及时修改的。谢谢。
wd 回复于:2004-06-11 16:28:50
虽然关键内容不是我的原创,比如那个脚本(我不会写脚本,呵呵),可是好歹也写了半天,呵呵。
欢
没有评论:
发表评论
写下你的意见和问题,一起进步。谢谢