Chinaunix首页 | 论坛 | 博客
  • 博客访问: 173169
  • 博文数量: 20
  • 博客积分: 542
  • 博客等级: 中士
  • 技术积分: 240
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-23 09:44
文章分类

全部博文(20)

文章存档

2012年(3)

2011年(17)

分类: LINUX

2011-08-18 14:55:13

ftp软件有许多,比如wuftp,proftp,vsftpd等,但对虚拟用户支持最好,且配置最为简单的我个人觉得非pureftp莫属,下面就来介绍下如何编译安装pureftp和配置虚拟用户!
下载相关包,并进行编译安装
[root@server ~]#cd /usr/local/src/tarbag/
[root@server tarbag]#tar -zxvf pure-ftpd-1.0.22.tar.gz -C ../software/
[root@server tarbag]#cd ../software/pure-ftpd-1.0.22/
[root@server pure-ftpd-1.0.22]#./configure --prefix=/usr/local/pureftpd --with-everything
[root@server pure-ftpd-1.0.22]#make && make install
[root@server pure-ftpd-1.0.22]#cp configuration-file/pure-config.pl /usr/local/pureftpd/bin/
[root@server pure-ftpd-1.0.22]#cp configuration-file/pure-ftpd.conf /usr/local/pureftpd/etc/
[root@server pure-ftpd-1.0.22]#cp contrib/redhat.init /etc/init.d/pureftpd (这个脚本可以用来实现自启动)

[root@server pure-ftpd-1.0.22]#ls ./*.conf
./pureftpd-ldap.conf ./pureftpd-mysql.conf ./pureftpd-pgsql.conf
[root@server pure-ftpd-1.0.22]#cp ./*.conf /usr/local/pureftpd/etc/
[root@server pure-ftpd-1.0.22]#chmod +x /usr/local/pureftpd/bin/pure-config.pl
修改相关配置文件如下:
[root@server ~]#grep -v '^#' /usr/local/pureftpd/etc/pure-ftpd.conf |sort |uniq

AllowAnonymousFXP 

          no
AllowUserFXP                no
AnonymousCanCreateDirs      no
AnonymousCantUpload         no
AnonymousOnly               no
AntiWarez                   yes
AutoRename                  no
BrokenClientsCompatibility no
ChrootEveryone              yes //锁定所有用户到家目录中
CustomerProof               yes
Daemonize                   yes
DisplayDotFiles             yes            //显示目录下的隐含文件
DontResolve                 yes               //不进行反向解析
LimitRecursion              2000 8             //别表最大显示2000个文件,最深8个目录
MaxClientsNumber            50       //最大的客户端数量
MaxClientsPerIP             8    //同一个IP允许8个链接
MaxDiskUsage                99       //磁盘的最大利用率
MaxIdleTime                 15       //最大空闲15分钟
MaxLoad                     4               //最多可下载的数量
MinUID                      1000 //用户ID至少要大于1000才能登陆
NoAnonymous                 yes    //不允许匿名用户登录
ProhibitDotFilesRead        no
ProhibitDotFilesWrite       no
PureDB                      /usr/local/pureftpd/etc/pureftpd.pdb //虚拟用户数据库
SyslogFacility              ftp
Umask                       133:022      //文件和目录的umask
VerboseLog                  no       / /不记录详细的日志信息

以上配置文件可根据实际需要进行调整,下面试启动下服务!
[root@server ~]#/usr/local/pureftpd/bin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf
Running: /usr/local/pureftpd/sbin/pure-ftpd -A -c50 -B -C8 -D -E -fftp -H -I15 -lpuredb:/usr/local/pureftpd/etc/pureftpd.pdb -L2000:8 -m4 -s -U133:022 -u1000 -k99 -Z
[root@server ~]#netstat -ntpl |grep 21tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      9553/pure-ftpd (SER
tcp        0      0 :::21                       :::*                        LISTEN      9553/pure-ftpd (SER

关闭服务:
[root@server ~]#killall pure-ftpd
[root@server ~]#netstat -ntpl |grep 21

添加虚拟用户在系统上所映射的用户和组:
[root@server ~]#groupadd -g 1000 ftpgroup
[root@server ~]#useradd -g ftpgroup -u 1000 -d /dev/null -s /sbin/nologin ftpuser
添加虚拟用户:
[root@server ~]#/usr/local/pureftpd/bin/pure-pw useradd zhang -u ftpuser -d /usr/local/src/ -m
Password:
Enter it again:
查看虚拟用户信息:
[root@server ~]#/usr/local/pureftpd/bin/pure-pw list
yang                /usr/local/src/./                                         
[root@server ~]#/usr/local/pureftpd/bin/pure-pw show yang

Login              : zhang
Password           : $1$3/SblBu0$cs./Rn31HFaiOgRDo6le60
UID                : 1000 (ftpuser)
GID                : 1000 (ftpgroup)
Directory          : /usr/local/src/./
Full name          :
Download bandwidth : 0 Kb (unlimited)
Upload   bandwidth : 0 Kb (unlimited)
Max files          : 0 (unlimited)
Max size           : 0 Mb (unlimited)
Ratio              : 0:0 (unlimited:unlimited)
Allowed local IPs :
Denied local IPs :
Allowed client IPs :
Denied client IPs :
Time restrictions : 0000-0000 (unlimited)
Max sim sessions   : 0 (unlimited)
设定自启动,修改相关配置文件如下:
[root@server ~]#grep '/usr/local' /etc/init.d/pureftpd
fullpath=/usr/local/pureftpd/bin/$prog
pureftpwho=/usr/local/pureftpd/sbin/pure-ftpwho
$fullpath /usr/local/pureftpd/etc/pure-ftpd.conf --daemonize
启动服务:
[root@server ~]#service pureftpd start
启动 pure-config.pl:Running: /usr/local/pureftpd/sbin/pure-ftpd --daemonize -A -c50 -B -C8 -D -E -fftp -H -I15 -lpuredb:/usr/local/pureftpd/etc/pureftpd.pdb -L2000:8 -m4 -s -U133:022 -u100 -k99 -Z

[root@server ~]#netstat -ntpl |grep 21
tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      10166/pure-ftpd (SE
tcp        0      0 :::21                       :::*                        LISTEN      10166/pure-ftpd (SE
测试使用虚拟用户登录:
[root@server ~]#ftp 127.0.0.1
Connected to 127.0.0.1.
220---------- Welcome to Pure-FTPd [privsep] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 16:07. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
500 This security scheme is not implemented
500 This security scheme is not implemented
KERBEROS_V4 rejected as an authentication type
Name (127.0.0.1:root): yang
331 User yang OK. Password required
Password:
230-User yang has group access to: 1000     
230 OK. Current directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/" is your current location
ftp> ls
227 Entering Passive Mode (127,0,0,1,172,137)
150 Accepted data connection
drwxr-xr-x    5 0          0                4096 Jan 13 12:46 .
drwxr-xr-x    5 0          0                4096 Jan 13 12:46 ..
drwxrwxrwx    8 0          0                4096 Jan 22 18:08 share
drwxr-xr-x   13 0          0                4096 Jan 25 15:11 software
drwxr-xr-x    3 0          0                4096 Jan 25 15:09 tarbag
226-Options: -a -l
226 5 matches total

修改虚拟用户的参数,更详细的参数可以使用pure-pw --help查看:
[root@server ~]#/usr/local/pureftpd/bin/pure-pw usermod zhang -R 192.168.90.20/24
[root@server ~]#/usr/local/pureftpd/bin/pure-pw show yang |grep 'IP'
Allowed local IPs :
Denied local IPs :
Allowed client IPs :
Denied client IPs : 192.168.90.20/24

阅读(2145) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~