首页 > 代码库 > pureftp部署和优化

pureftp部署和优化

ftp == file transfer protocol 文件传输协议,使用ftp服务,可以上客户端远程下载和上传服务端的文件。系统自带的ftp工具是vsftpd,我们也可以使用pure-ftpd工具。下载pure-ftpd的链接:

官网:www.pureftpd.org

教程:www.aminglinux.com/study_v2/chapter21.html

服务端192.168.147.137:

进入源码目录:

[root@cp1 src]# cd /usr/local/src

下载安装包:

[root@cp1 src]# wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.42.tar.bz2

解压安装包:

[root@cp1 src]# tar jxvf pure-ftpd-1.0.42.tar.bz2

进入安装目录:

[root@cp1 src]# cd pure-ftpd-1.0.42

配置安装选项:

[root@cp1 pure-ftpd-1.0.42]# ./configure --prefix=/usr/local/pureftpd --without-inetd --with-altlog --with-puredb --with-throttling --with-peruserlimites --with-tls

编译:

[root@cp1 pure-ftpd-1.0.42]# make

安装:

[root@cp1 pure-ftpd-1.0.42]# make install

创建配置文件目录:

[root@cp1 pure-ftpd-1.0.42]# mkdir -p /usr/local/pureftpd/etc

拷贝模板配置文件:

[root@cp1 pure-ftpd-1.0.42]# cp configuration-file/pure-ftpd.conf /usr/local/pureftpd/etc/

拷贝启动文件:

[root@cp1 pure-ftpd-1.0.42]# cp configuration-file/pure-config.pl /usr/local/pureftpd/sbin/

更改启动文件权限:

[root@cp1 pure-ftpd-1.0.42]# chmod 755 /usr/local/pureftpd/sbin/pure-config.pl

编辑配置文件:

[root@cp1 pure-ftpd-1.0.42]# vim /usr/local/pureftpd/etc/pure-ftpd.conf

修改内容如下:

ChrootEveryone              yes BrokenClientsCompatibility  no MaxClientsNumber            50 Daemonize                   yes MaxClientsPerIP             8 VerboseLog                  no DisplayDotFiles             yes AnonymousOnly               no NoAnonymous                 no SyslogFacility              ftp DontResolve                 yes MaxIdleTime                 15PureDB                        /usr/local/pureftpd/etc/pureftpd.pdbLimitRecursion              3136 8 AnonymousCanCreateDirs      no MaxLoad                     4 AntiWarez                   yes Umask                       133:022 MinUID                      100 AllowUserFXP                no AllowAnonymousFXP           no ProhibitDotFilesWrite       no ProhibitDotFilesRead        no AutoRename                  no AnonymousCantUpload         noPIDFile                     /usr/local/pureftpd/var/run/pure-ftpd.pidMaxDiskUsage               99 CustomerProof              yes

(最小UID为100,映射的UID要大于这个值,/usr/local/pureftpd/etc/pureftpd.pdb为存放用户名密码的库文件)

创建一个测试目录:

[root@cp1 pure-ftpd-1.0.42]# mkdir /tmp/ftp

改变其属主:

[root@cp1 pure-ftpd-1.0.42]# chown -R rachy /tmp/ftp/

添加一个用于登陆ftp服务器的虚拟用户ftpuser1,并将系统用户rachy映射到该虚拟用户:

[root@cp1 pure-ftpd-1.0.42]# /usr/local/pureftpd/bin/pure-pw useradd ftpuser1 -urachy -d /tmp/ftp/

Password:

Enter it again:

生成密码库文件:

[root@cp1 pure-ftpd-1.0.42]# /usr/local/pureftpd/bin/pure-pw mkdb

(也可以查看内容:/usr/local/pureftpd/bin/pure-pw list)

(也可以删除用户:/usr/local/pureftpd/bin/pure-pw userdel ftpuser1)

启动pureftpd服务:

[root@cp1 pure-ftpd-1.0.42]# /usr/local/pureftpd/sbin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf

Running: /usr/local/pureftpd/sbin/pure-ftpd -A -c50 -B -C8 -D -fftp -H -I15 -lpuredb:/usr/local/pureftpd/etc/pureftpd.pdb -L3136:8 -m4 -s -U133:022 -u100 -g/usr/local/pureftpd/var/run/pure-ftpd.pid -k99 -Z

查看进程:

[root@cp1 pure-ftpd-1.0.42]# ps aux | grep pure

root      7146  0.0  0.0   9000   588 ?        Ss   21:45   0:00 pure-ftpd (SERVER)                                                                                                                        

root      7148  0.0  0.0   5980   756 pts/0    S+   21:46   0:00 grep pure

查看端口:

[root@cp1 pure-ftpd-1.0.42]# netstat -lnp | grep pure

tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      7146/pure-ftpd (SER

tcp        0      0 :::21                       :::*                        LISTEN      7146/pure-ftpd (SER

客户端192.168.147.138:

安装lftp命令:

[root@cp2 ~]# yum install -y lftp

登陆ftp服务器:

[root@cp2 ~]# lftp ftpuser1@192.168.147.137

口令:

lftp ftpuser1@192.168.147.137:~> ?

登陆之后,输入?查看ftp支持的命令

下载文件:

[root@cp2 download]# ls

2.txt

[root@cp2 download]# lftp ftpuser1@192.168.147.137

口令:

lftp ftpuser1@192.168.147.137:~> ls

drwxr-xr-x    2 502        0                4096 Feb 26 21:57 .

drwxr-xr-x    2 502        0                4096 Feb 26 21:57 ..

-rw-r--r--    1 0          0                   5 Feb 26 21:57 1.txt

lftp ftpuser1@192.168.147.137:/> get 1.txt

5 bytes transferred

lftp ftpuser1@192.168.147.137:/> exit

[root@cp2 download]# ls

1.txt  2.txt

[root@cp2 download]#

上传文件:

lftp ftpuser1@192.168.147.137:~> ls

drwxr-xr-x    2 502        0                4096 Feb 26 21:57 .

drwxr-xr-x    2 502        0                4096 Feb 26 21:57 ..

-rw-r--r--    1 0          0                   5 Feb 26 21:57 1.txt

lftp ftpuser1@192.168.147.137:/> put 2.txt

5 bytes transferred

lftp ftpuser1@192.168.147.137:/> ls

drwxr-xr-x    2 502        0                4096 Feb 26 21:59 .

drwxr-xr-x    2 502        0                4096 Feb 26 21:59 ..

-rw-r--r--    1 0          0                   5 Feb 26 21:57 1.txt

-rw-r--r--    1 502        rachy               5 Feb 26 21:56 2.txt

lftp ftpuser1@192.168.147.137:/>

也可以使用ftp命令登陆,跟lftp类似:

安装ftp客户端:

[root@cp2 download]# yum install -y ftp

登录ftp服务器:

[root@cp2 download]# ftp 192.168.147.137

Connected to 192.168.147.137 (192.168.147.137).

220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------

220-You are user number 1 of 50 allowed.

220-Local time is now 22:01. Server port: 21.

220-IPv6 connections are also welcome on this server.

220 You will be disconnected after 15 minutes of inactivity.

Name (192.168.147.137:root): ftpuser1

331 User ftpuser1 OK. Password required

Password:

230 OK. Current directory is /

Remote system type is UNIX.

Using binary mode to transfer files.

ftp> ls

227 Entering Passive Mode (192,168,147,137,210,129)

150 Accepted data connection

drwxr-xr-x    2 502        0                4096 Feb 26 22:03 .

drwxr-xr-x    2 502        0                4096 Feb 26 22:03 ..

-rw-r--r--    1 0          0                   5 Feb 26 21:57 1.txt

226-Options: -a -l

226 3 matches total

下载文件:

ftp> get 1.txt

local: 1.txt remote: 1.txt

227 Entering Passive Mode (192,168,147,137,206,50)

150 Accepted data connection

226-File successfully transferred

226 0.000 seconds (measured here), 14.27 Kbytes per second

5 bytes received in 3.1e-05 secs (161.29 Kbytes/sec)

ftp> exit

221 Goodbye. You uploaded 0 and downloaded 1 kbytes.

[root@cp2 download]# ls

1.txt  2.txt

上传文件:

ftp> put 2.txt

local: 2.txt remote: 2.txt

227 Entering Passive Mode (192,168,147,137,130,188)

150 Accepted data connection

226-File successfully transferred

226 0.001 seconds (measured here), 7.76 Kbytes per second

5 bytes sent in 0.000164 secs (30.49 Kbytes/sec)

ftp> ls

227 Entering Passive Mode (192,168,147,137,136,65)

150 Accepted data connection

drwxr-xr-x    2 502        0                4096 Feb 26 22:05 .

drwxr-xr-x    2 502        0                4096 Feb 26 22:05 ..

-rw-r--r--    1 0          0                   5 Feb 26 21:57 1.txt

-rw-r--r--    1 502        rachy               5 Feb 26 22:05 2.txt

226-Options: -a -l

226 4 matches total

ftp>

windows上只需安装ftp客户端即可访问ftp服务器。


pureftp部署和优化