一、什麼是FTP數據庫
FTP(file transfer protocol)文件傳輸協議,能夠使主機之間共享文件。vim
二、使用pure-ftp搭建FTP服務併發
下載pure-ftp軟件包
less
[root@localhost src]# wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.32.tar.bz2
解壓安裝包
ssh
[root@localhost src]# tar jxvf pure-ftpd-1.0.32.tar.bz2
配置pure-ftptcp
[root@localhost src]# cd pure-ftpd-1.0.32 [root@localhost pure-ftpd-1.0.32]# ./configure --prefix=/usr/local/pureftpd --without-inetd --with-altlog --with-puredb --with-throttling --with-peruserlimits --with-tls
編譯安裝ide
[root@localhost pure-ftpd-1.0.32]# make && make install
查看/usr/local/pureftpd/目錄下生成的文件this
[root@localhost pure-ftpd-1.0.32]# ls /usr/local/pureftpd/ bin sbin share
複製配置文件server
[root@localhost pure-ftpd-1.0.32]# mkdir -p /usr/local/pureftpd/etc/ [root@localhost pure-ftpd-1.0.32]# cd configuration-file/ [root@localhost configuration-file]# ls Makefile Makefile.in pure-config.pl.in pure-config.py.in pure-ftpd.conf.in Makefile.am pure-config.pl pure-config.py pure-ftpd.conf [root@localhost configuration-file]# cp pure-ftpd.conf /usr/local/pureftpd/etc/ [root@localhost configuration-file]# cp pure-config.pl /usr/local/pureftpd/sbin/pure-config.pl [root@localhost configuration-file]# chmod 755 /usr/local/pureftpd/sbin/pure-config.pl
編寫配置文件pure-ftpd.conf
token
[root@localhost configuration-file]# vim /usr/local/pureftpd/etc/pure-ftpd.conf ChrootEveryone yes //用戶只能在他的家目錄 BrokenClientsCompatibility no MaxClientsNumber 50 //最大併發的用戶 Daemonize yes //在後臺運行進程 MaxClientsPerIP 8 VerboseLog no //If you want to log all client commands, set this to "yes". DisplayDotFiles yes AnonymousOnly no //Don't allow authenticated users - have a public anonymous FTP only. NoAnonymous no //Disallow anonymous connections. Only allow authenticated users. SyslogFacility ftp DontResolve yes // Don't resolve host names in log files. Logs are less verbose, // butit uses less bandwidth. Set this to "yes" on very busy servers or //if you don't have a working DNS. MaxIdleTime 15 //Maximum idle time in minutes (default = 15 minutes) PureDB /usr/local/pureftpd/etc/pureftpd.pdb //用戶數據庫 LimitRecursion 3136 8 //'ls' recursion limits. The first argument is the maximum number offiles to be displayed. //The second one is the max subdirectories depth AnonymousCanCreateDirs no //Are anonymous users allowed to create new directories ? MaxLoad 4 //If the system is more loaded than the following //value,anonymous users aren't allowed to download. AntiWarez yes //Disallow downloading of files owned by "ftp", ie.files that were uploaded but not validated by a local admin. Umask 133:022 //File creation mask. <umask for files>:<umask for dirs> . MinUID 100 //Minimum UID for an authenticated user to log in. AllowUserFXP no //Allow FXP transfers for authenticated users. AllowAnonymousFXP no //Allow anonymous FXP for anonymous and non-anonymous users. ProhibitDotFilesWrite no // Users can't delete/write files beginning with a dot ('.')even if they own them. ProhibitDotFilesRead no // Prohibit *reading* of files beginning with a dot (.history, .ssh...) AutoRename no //Never overwrite files. When a file whoose name already exist is uploaded, //it get automatically renamed to file.1, file.2, file.3, ... AnonymousCantUpload no // Disallow anonymous users to upload new files (no = upload is allowed) PIDFile /usr/local/pureftpd/var/run/pure-ftpd.pid //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 MaxDiskUsage 99 CustomerProof yes //If you're sure all your users have some basic Unix knowledge, //this feature is useless. If you're a hosting service, enable it.
建立FTP服務目錄
[root@localhost configuration-file]# mkdir /data/ftp [root@localhost configuration-file]# useradd www [root@localhost configuration-file]# passwd www Changing password for user www. New password: BAD PASSWORD: it is too simplistic/systematic BAD PASSWORD: is too simple Retype new password: passwd: all authentication tokens updated successfully. [root@localhost configuration-file]# chown -R www:www /data/ftp //更改屬主屬組
用系統帳號需建立虛擬FTP帳號
[root@localhost configuration-file]# /usr/local/pureftpd/bin/pure-pw useradd ftp1 -uwww -d/data/ftp Password: Enter it again: //建立虛擬帳號 [root@localhost configuration-file]# /usr/local/pureftpd/bin/pure-pw mkdb //建立密碼文件,二進制文件 [root@localhost configuration-file]# /usr/local/pureftpd/bin/pure-pw list ftp1 /data/ftp/./ //列出虛擬帳號 [root@localhost configuration-file]# /usr/local/pureftpd/bin/pure-pw useradd ftp2 -uwww -d /data/ftp Password: Enter it again: ][root@localhost configuration-file]# /usr/local/pureftpd/bin/pure-pw passwd ftp2 Password: Enter it again: //修改虛擬帳號密碼 [root@localhost configuration-file]# /usr/local/pureftpd/bin/pure-pw userdel ftp2 //刪除虛擬帳號 [root@localhost configuration-file]# /usr/local/pureftpd/bin/pure-pw list ftp1 /data/ftp/./
啓動pure-ftp
[root@localhost configuration-file]# /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@localhost configuration-file]# netstat -anpt |grep pure tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 6721/pure-ftpd (SER tcp 0 0 :::21 :::* LISTEN 6721/pure-ftpd (SER
訪問pure-ftp
[root@client ~]# lftp ftp1@192.168.0.104 //客戶機 Password: lftp ftp1@192.168.0.104:~> ls drwxr-xr-x 5 504 www 4096 Apr 22 11:02 . drwxr-xr-x 5 504 www 4096 Apr 22 11:02 .. drwxr-xr-x 2 0 0 4096 Apr 22 11:02 aa drwxr-xr-x 2 0 0 4096 Apr 22 11:02 bb drwxr-xr-x 2 0 0 4096 Apr 22 11:02 cc -rw-r--r-- 1 0 0 0 Apr 22 11:02 ee -rw-r--r-- 1 0 0 0 Apr 22 11:02 qq -rw-r--r-- 1 0 0 0 Apr 22 11:02 ww