Chinaunix首页 | 论坛 | 博客
  • 博客访问: 673266
  • 博文数量: 176
  • 博客积分: 4791
  • 博客等级: 上校
  • 技术积分: 1921
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-24 18:47
个人简介

it江湖漂,怎能不挨刀;一朝机器当,看你怎么着!

文章分类

全部博文(176)

文章存档

2014年(2)

2012年(17)

2011年(27)

2010年(18)

2009年(6)

2008年(21)

2007年(43)

2006年(42)

分类: LINUX

2006-07-25 18:14:54

                                              cxm.cm:2006.7.26
目的:
安装配置一个proftpd,达到以下要求
1  不允许匿名访问。
 
   su root //输入root的密码。

1  下载proftpd
地址:。这里我们下载了1.2.9版本
    wget

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 vi /usr/local/proftpd/etc/proftpd.conf
 
ServerName                      "download.yulequan.com"
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 limit maximum number of processes per service
# (such as xinetd).
MaxInstances                    30
# Set the user and group under which the server will run.
#User                           nobody
#Group                          nogroup
User                            www
Group                           www
# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
DefaultRoot ~
# Normally, we want files to be overwriteable.
AllowOverwrite on
MaxLoginAttempts 5
TimeoutLogin 300
TimeoutIdle 600
TimeoutNoTransfer 900
TimeoutStalled 3600
MaxClients 100
MaxClientsPerHost 30
AllowRetrieveRestart on
AllowStoreRestart on
UseReverseDNS off
RootLogin off
RequireValidShell off
# Bar use of SITE CHMOD by default

  DenyAll


       
                DenyGroup www
       

以上的配置就可以完成了功能
下面是一些其他的功能配置:
设置只允许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
;
;
#####结束######

针对一些具体权限的设定
CMD:Change Working Directory 改变目录
MKD:MaKe Directory 建立目录的权限
RNFR: ReName FRom 更改目录名的权限
DELE:DELEte 删除文件的权限
RMD:ReMove Directory 删除目录的权限
RETR:RETRieve 从服务端下载到客户端的权限
STOR:STORe 从客户端上传到服务端的权限
READ:可读的权限,不包括列目录的权限,相当于RETR,STAT等
WRITE:写文件或者目录的权限,包括MKD和RMD
DIRS:是否允许列目录,相当于LIST,NLST等权限,还是比较实用的
ALL:所有权限
LOGIN:是否允许登陆的权限
 
针对上面这个Limit所应用的对象,又包括以下范围 
AllowUser 针对某个用户允许的Limit
DenyUser 针对某个用户禁止的Limit
AllowGroup 针对某个用户组允许的Limit
DenyGroup 针对某个用户组禁止的Limit
AllowAll 针对所有用户组允许的Limit
DenyAll 针对所有用户禁止的Limit
 
关于限制速率的参数为: 
TransferRate STOR|RETR 速度(Kbytes/s) user 使用者

下面我们以例子来解说proftp的配置,这样大家可能更加容易理解。
1。ftp服务器支持断点续传,且最大支持同时10人在线,每个ip只允许一个连接;
2。允许ftpusers用户组只能访问自己的目录,而不能访问上级或者其他目录;
3。用户登陆服务器时不显示ftp服务器版本信息,以增加安全性;
4。建立一个kaoyan的ftp帐户,属于ftpusers组,kaoyan用户只允许下载,没有可写的权限。下载速率限制在50Kbytes/s。
5。建立一个upload用户,也属于ftpusers组,同kaoyan用户的宿主目录一样,允许upload用户上传文件和创建目录的权限,但不允许下载,并且不允许删除目录和文件的权限,上传的速率控制在100Kbytes/s
先是前期的用户和组添加以及目录的权限设置

group add ftpusers
useradd -d /home/kaoyan -g ftpusers -s /bin/fales kaoyan
useradd -d /home/kaoyan -g ftpusers -s /bin/fales upload
chown -R kaoyan:upload /home/kaoyan
chmod -R 775 /home/kaoyan

如果你只想ftpusers组的用户访问,可以设置成770都行。
设置/usr/local/proftpd/etc/proftpd.conf
注意#表示注释,对设置没影响,可以不写

ServerName "Frank's FTP Server"
ServerType standalone
DefaultServer on
Port 21
Umask 022
MaxInstances 30 #最多有30个proftpd的PID
User nobody
Group nobody
TimeoutStalled 10
MaxClients 10 #最多允许10个用户在线
MaxClientsPerHost 1 "对不起,一个IP只允许一个连接"
AllowStoreRestart on
#允许断点续传(上传),断点续续(下载)是默认支持的,不用设置
DisplayLogin welcome.msg #欢迎词文件
ServerIdent off #屏蔽服务器版本信息
DefaultRoot ~ ftpusers #设置ftpusers组只能访问自己的目录
;
AllowOverwrite on
;
;
; #不允许写
DenyUser kaoyan
;
; #不允许删除,改名,下载
DenyUser upload
;
TransferRate RETR 50 user kaoyan
TransferRate STOR 100 user upload
;

千万注意在所有的设定完后一定要重起FTP的服务
KILL 掉FTP服务,
CD /usr/local/proftpd/sbin目录下
  A ./ftpshut now
  B ./proftpd
  C  rm /etc/shutmsg
阅读(1024) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~