前几天为了让公司内的FTP,决定在centos5下装支持虚拟用户带磁盘限额的FTP软件。在安装PureFTPd以前,要做好以下准备工作:
安装PureFTPd
1.下面我们开始安装PureFTPd,同样以FreeBSD的Ports方式安装。
| 以下为引用的内容: #tar zxfv pure-ftpd-1.0.21.tar.gz -C /usr/local/ #cd /usr/local/pure-ftpd-1.0.21/ #./configure \ --prefix=/usr/local/pureftpd \ --with-mysql \ --with-puredb \ --with-paranoidmsg \ --with-peruserlimits \ --with-shadow \ --with-welcomemsg \ --with-uploadscript \ --with-quotas \ --with-cookie \ --with-pam \ --with-virtualhosts \ --with-virtualroot \ --with-virtualchroot \ --with-diraliases \ --with-sysquotas \ --with-ratios \ --with-ftpwho \ --with-throttling \ --with-largefile \ --with-language=simplified-chinese \ --with-altlog \ --with-iplogging \ --without-usernames #make # make check # make install 下面配置pureftpd: # mkdir –pv /usr/local/pureftpd/etc #cp pureftpd-mysql.conf /usr/local/pureftpd/etc # cp configuration-file/pure-config.pl /usr/local/pureftpd/sbin/ (生成配置文件) # cp configuration-file/pure-ftpd.conf /usr/local/pureftpd/etc/ # chmod 755 /usr/local/pureftpd/sbin/pure-config.pl # cd contrib 编辑 redhat.init 文件。找到语句 找到语句: "pureftpwho=/usr/local/sbin/pure-ftpwho", 将其改为: "pureftpwho=/usr/local/pureftpd/sbin/pure-ftpwho" 找到语句: ”$fullpath /usr/local/etc/pure-ftpd.conf –daemonize” 将其改为: ”$fullpath /usr/local/pureftpd/etc/pure-ftpd.conf –daemonize” 执行以下命令将文件 redhat.init 复制到 /etc 目录中重命名为 pure-ftpd,并将其设置为可执行。 # cp redhat.init /etc/rc.d/init.d/pureftpd # chmod u+x /etc/rc.d/init.d/pureftpd # /sbin/chkconfig --add pureftpd ( 将 pure-ftpd 服务添加到系统中 ) # /sbin/chkconfig –level 2345 pureftpd on #serv ice pureftpd start 解释: 注明:) 在README中[ADVANCED COMPILATION]的段落中,有对上面的使用的 详细说明.在这里对常用的做简略的解释. --without-standalone 不能以standalone的方式执行ftpd. --without-inetd 不能以inetd的方式执行ftpd. --without-iplogging 做log時不将IP 地址给log下來. --without-shadow 不做shadow.除非是用PAM, LDAP or SQL.不然极不建议拿掉. --without-usernames 文件列表只会列出UID & GID,不列出实际user or group name. --without-humor 嘿嘿嘿.... --without-ascii 不支持7-bits transfers(ASCII). --with-paranoidmsg 唔....不知该怎么说.算是可以给特定人的信息吧. --with-sysquotas 吃系统的quota设定. --with-minimal 最小化安裝. --with-pam --with-puredb --with-ldap --with-mysql --with-pgsql 以上五种都是存储资料的格式?.看你比较习惯什么. --with-altlog 留log了.... --with-cookie 使用者进站看到的东东.类似进站画面. --with-ratios 上下传比. --with-throttling 频宽可设限. --with-ftpwho 可用pure-ftpwho來看线上使用者.像是Serv-u的线上状态. --with-uploadscript 当一个文件被完整上传完后自动呼叫某一script去对这个文件处理.当然.这个script得你自己写. --with-largefile 支持下载超过2G的文件. --with-virtualhosts 跟http的virtualhost有异曲同工之妙. --with-virtualchroot 配合上面的chroot. --with-diraliases 跟Serv-U上面的link功能一样. --with-nonroot 不需root权限.一般user即可启动ftpd. --with-quotas 使用quota.(非系统下的quota) --with-peruserlimits 每个账号最多可登入几次:Anonymous最多可同時登入几次 --with-everything 所有功能全上. --with-language=simplified-chinese 显示出来的信息的语言.缺省为英语. |
安装完后,就会在/usr/local目录下生成一个pureftpd目录,我们要使用的文件都在这个目录中。
2.下面我们开始配置pure-ftpd.conf文件
在这里我全使用默认值,修改下面内容以支持MYSQL。(注:Pureftpd可以同时支持ldap,mysql,pgsql,puredb认证)
| 以下为引用的内容: # MySQL configuration file (see README.MySQL) MySQLConfigFile /usr/local/pureftpd/etc/pureftpd-mysql.conf 修改不然无法执行 #service pureftpd stop) # If your pure-ftpd has been compiled with standalone support, you can change # the location of the pid file. The default is /var/run/pure-ftpd.pid #PIDFile /var/run/pure-ftpd.pid #去掉上面的注释 PIDFile /var/run/pure-ftpd.pid 修改不允许名登陆 NoAnonymous yes # Allow FXP transfers for authenticated users. AllowUserFXP yes # Allow users to resume and upload files, but *NOT* to delete them. KeepAllFiles yes # Automatically create home directories if they are missing CreateHomeDir yes |
3.配置文件详解(摘自网上陈景峰所著《Pure-FTPd + LDAP + MySQL + PGSQL + Virtual-Users + Quota How To》)
ChrootEveryone yes
chroot每一个用户,等同于Proftpd 中的DefaultRoot~ , 可以限制用户在某个地方活动,增强服务器的安全性。使用过wu-ftpd的使用都应该知道cd /会发生什么!
| 以下为引用的内容: TrustedGID 50 #以上两者要一起用 BrokenClientsCompatibility no MaxClientsNumber 50 #最大链接数 Daemonize yes #Fork in background 以守护进程方式在后台运行 MaxClientsPerIP 5 #每个ip最多链接数,最好设小点。 VerboseLog no #是否要把所有client端的指令都log下来 DisplayDotFiles no #显示开头的文件 AnonymousOnly no #是否只让匿名登录 NoAnonymous no #不开放匿名登入 SyslogFacility ftp #应该是对日志做一下过滤 (auth, authpriv, daemon, ftp, security, user, local*)可以让日志只记录想要的信息 DontResolve yes #不反向解释客户端的ip MaxIdleTime 5 #最大闲置時間 #LDAPConfigFile /usr/local/pureftpd/etc/pureftpd-ldap.conf #使用LDAP认证, MySQLConfigFile /usr/local/pureftpd/etc/pureftpd-mysql.conf #使用MySQL认证 #PGSQLConfigFile /usr/local/pureftpd/etc/pureftpd-pgsql.conf #使用PGSQL认证 #PureDB /ftp/etc/pureftpd.pdb #使用者资料的DB存放地点 [由于我是用PureFTPD的內建DB.固有此选项] #ExtAuth /var/run/ftpd.sock #pure-authd socket 路径 (详细请看 README.Authentication-Modules) #PAMAuthentication yes #开启PAM认证 #UnixAuthentication yes #如果你想要有简单的Unix(/etc/passwd)的认证的話 FortunesFile /usr/local/pureftpd/etc/.welcome #显示的欢迎信息文件,你可以创建该文件,输入一些文字,然后你重启你的FTP服务,就会有意外的发现。 LimitRecursion 2000 8 #ls最多列出3000个文件.最深8层 AnonymousCanCreateDirs no #匿名用户可以创建目录 MaxLoad 4 #当system load超过4時.使用者将不能再下载 PassivePortRange 30000 50000 #被动连接应答范围 ForcePassiveIP 192.168.0.1 #不会译:( AnonymousRatio 1 10 #Anonymous连接上传/下载比率 UserRatio 1 10 #用户上传/下载比率(注:如果使用ldap,mysql,pgsql,pam不要启用该功能,否则你在ldap等中设置的Ratio无校) AntiWarez no #上传的文件不能被下载(owner is ftp).等到local admin确认 Bind 127.0.0.1,8021 #要绑定和ip/port,在你的系统中有两个FTP Server这样你其中一个FTP就要使用其它端口。 #格式-> 127.0.0.1,21 如果只写port表All ip,port AnonymousBandwidth 8 #Anonymous 带宽,单位KB/s UserBandwidth 8 #用户带宽,单位KB/s Umask 133:022 #上传文件的Umask.(<umask for files>:<umask for dirs> ) MinUID 1000 # UID至少多少才能登录 AllowUserFXP yes #支不支持FXP AllowAnonymousFXP no #Anonymous支不支持FXP ProhibitDotFilesWrite no ProhibitDotFilesRead no #(”.”)开头的文件能不能被读/写,UNIX Like下以点开头的文件是隐藏文件ls –a才能列出 #Pureftpd Quota模式下做产生” .ftpquota”文件。 AutoRename no #上传文件若有相同文件名自动改名(file.1,file.2...) AnonymousCantUpload no #匿名用户上传文件 #TrustedIP 10.1.1.1 #锁IP. LogPID #Log文件添加PID AltLog stats:/ftp/etc/log/pureftpd.log #log存放地点,注日志有几种常用的格式 #clf 类似apache格式,stats UNIX log格式,w3c 标准W3C格式,可能是HTML格式 NoChmod yes #不给Chmod指令的权限 KeepAllFiles no #使用者可续传.但不可刪除文件 CreateHomeDir yes #如果user的home不存在自动建立(我把这个设为YES) Quota 1000:10 #Quota <文件数>:<容量Megabytes >,FTP限制10M空间,可以上传1000个文件(注:如果使用ldap,mysql,pgsql,pam不要启用该功能,否则你在ldap等中设置的Quota无校) PIDFile /ftp/etc/log/pure-ftpd.pid #记录pure-ftpd的PID文件 CallUploadScript yes #呼叫UploadScript MaxDiskUsage 99 #当硬盘使用率到多少時将停止上传 NoRename yes #用户不能重命名文件名 CustomerProof yes PerUserLimits 3:20 #<每个账号最多可登入几次:Anonymous最多可同時登入几次> |

RSS订阅