
Pure-FTP
一、安裝 pure-ftp
#默認(rèn)的yum源不包含pure-ftpd,需先安裝epel擴(kuò)展源
yum install -y epel-release
yum install -y pure-ftpd
二、配置 pure-ftp
1、創(chuàng)建 ftp 系統(tǒng)用戶
# 創(chuàng)建用戶 ftp
useradd ftp -s /sbin/nologin
2、配置FTP存儲(chǔ)根目錄
# 創(chuàng)建 FTP 存儲(chǔ)根目錄
mkdir /data/ftp
# 設(shè)置 FTP 根目錄權(quán)限
chown -R ftp.ftp /data/ftp/
3、編輯 pure-ftp 配置文件
編輯 pure-ftp 配置文件 /etc/pure-ftpd/pure-ftpd.conf 部分參數(shù)如下:
# PureDB 用戶數(shù)據(jù)庫(kù)路徑(重要)
PureDB /etc/pure-ftpd/pureftpd.pdb
# 鎖定所有用戶到家目錄中
ChrootEveryone yes
# 如果虛擬用戶的目錄不存在則自動(dòng)創(chuàng)建
CreateHomeDir yes
# 兼容不同客戶端
BrokenClientsCompatibility yes
# 顯示隱藏文件
DisplayDotFiles no
# 防止命令誤操作
CustomerProof yes
# 被動(dòng)模式端口范圍
PassivePortRange 30000 50000
# 被動(dòng)模式 IP
ForcePassiveIP 192.168.1.100
# 只允許匿名用戶訪問(wèn)
AnonymousOnly no
# 不允許匿名用戶訪問(wèn)(為 no 時(shí)允許)
NoAnonymous yes
# 不允許匿名用戶上傳文件(為 no 時(shí)允許)
AnonymousCantUpload yes
# 不允許匿名用戶創(chuàng)建目錄(為 no 時(shí)允許)
AnonymousCanCreateDirs yes
# 僅運(yùn)行認(rèn)證用戶進(jìn)行FXP傳輸
AllowUserFXP no
# 對(duì)匿名用戶和非匿名用戶允許進(jìn)行匿名 FXP 傳輸
AllowAnonymousFXP no
# 設(shè)置日志的告警級(jí)別,默認(rèn)為 ftp,none 是禁止記錄日志
SyslogFacility none
4、創(chuàng)建 ftp 虛擬用戶
# 創(chuàng)建 ftp 用戶 aaa 家目錄
mkdir /data/ftp/aaa
chown -R ftp.ftp /data/ftp/aaa/
# 創(chuàng)建 ftp 用戶 aaa, -u 是將虛擬用戶 aaa 與系統(tǒng)用戶 ftp 關(guān)聯(lián)在一起,aaa 賬號(hào)登錄后是以 ftp 的身份來(lái)讀取和下載文件,-d 是指定ftp_usera賬戶的家目錄,這樣可以使用戶 aaa 只能訪問(wèn)其家目錄 /data/ftp/aaa/。
pure-pw useradd aaa -u ftp -d /data/ftp/aaa/
# 創(chuàng)建用戶信息數(shù)據(jù)庫(kù)文件,這一步很關(guān)鍵。
pure-pw mkdb
# 查看已創(chuàng)建的賬號(hào)列表
pure-pw list
5、啟動(dòng) pure-ftp 服務(wù)
# 啟動(dòng) pure-ftp 服務(wù)
systemctl start pure-ftpd.service
# 添加開(kāi)機(jī)啟動(dòng)項(xiàng)
systemctl enable pure-ftpd.service
# 或使用
systemctl enable --now pure-ftpd.service
6、使用客戶端測(cè)試連接
使用 Windows 或 Linux 客戶端登錄 FTP 測(cè)試服務(wù)是否正常。
三、配置文件 /etc/pure-ftpd/pure-ftpd.conf 完整參數(shù)說(shuō)明
############################################################
# #
# Configuration file for pure-ftpd wrappers #
# #
############################################################
# If you want to run Pure-FTPd with this configuration
# instead of command-line options, please run the
# following command :
#
# /usr/local/pureftpd/sbin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf
#
# Please don't forget to have a look at documentation at
# http://www.pureftpd.org/documentation.shtml for a complete list of
# options.
# Cage in every user in his home directory
# 鎖定所有用戶到家目錄中
ChrootEveryone yes
# If the previous option is set to "no", members of the following group
# won't be caged. Others will be. If you don't want chroot()ing anyone,
# just comment out ChrootEveryone and TrustedGID.
# 信任組ID100,可以不鎖定
# TrustedGID 100
# Turn on compatibility hacks for broken clients
# 兼容不同客戶端
BrokenClientsCompatibility no
# Maximum number of simultaneous users
# 最大的客戶端數(shù)量
MaxClientsNumber 50
# Fork in background
# 后臺(tái)運(yùn)行
Daemonize yes
# Maximum number of sim clients with the same IP address
# 每個(gè)ip最大連接數(shù)
MaxClientsPerIP 8
# If you want to log all client commands, set this to "yes".
# This directive can be duplicated to also log server responses.
# 記錄日志
VerboseLog no
# List dot-files even when the client doesn't send "-a".
# 顯示隱藏文件
DisplayDotFiles no
# Don't allow authenticated users - have a public anonymous FTP only.
# 只允許匿名用戶訪問(wèn)
AnonymousOnly no
# Disallow anonymous connections. Only allow authenticated users.
# 不允許匿名用戶
NoAnonymous yes
# Syslog facility (auth, authpriv, daemon, ftp, security, user, local*)
# The default facility is "ftp". "none" disables logging.
# 設(shè)置日志的告警級(jí)別,默認(rèn)為ftp,none是禁止記錄日志
SyslogFacility ftp
# Display fortune cookies
# 定制用戶登陸后的顯示信息
# FortunesFile /usr/share/fortune/zippy
# Don't resolve host names in log files. Logs are less verbose, but
# it uses less bandwidth. Set this to "yes" on very busy servers or
# if you don't have a working DNS.
# 是否在日志文件中進(jìn)行主機(jī)名解析,不進(jìn)行客戶端DNS解析
DontResolve yes
# Maximum idle time in minutes (default = 15 minutes)
# 最大空閑時(shí)間
MaxIdleTime 30
# LDAP configuration file (see README.LDAP)
# LDAP 配置文件路徑
# LDAPConfigFile /etc/pureftpd-ldap.conf
# MySQL configuration file (see README.MySQL)
# MySQL 配置文件路徑
MySQLConfigFile /usr/local/pureftpd/etc/pureftpd-mysql.conf
# Postgres configuration file (see README.PGSQL)
# Postgres 配置文件路徑
# PGSQLConfigFile /etc/pureftpd-pgsql.conf
# PureDB user database (see README.Virtual-Users)
# PureDB 用戶數(shù)據(jù)庫(kù)路徑
PureDB /usr/local/pureftpd/etc/pureftpd.pdb
# Path to pure-authd socket (see README.Authentication-Modules)
# pure-authd 的socket 路徑
# ExtAuth /var/run/ftpd.sock
# If you want to enable PAM authentication, uncomment the following line
# 如果你要啟用 PAM 認(rèn)證方式, 去掉下面行的注釋
# PAMAuthentication yes
# If you want simple Unix (/etc/passwd) authentication, uncomment this
# 如果你要啟用 簡(jiǎn)單的 Unix系統(tǒng) 認(rèn)證方式(/etc/passwd), 去掉下面行的注釋
# UnixAuthentication yes
# Please note that LDAPConfigFile, MySQLConfigFile, PAMAuthentication and
# UnixAuthentication can be used only once, but they can be combined
# together. For instance, if you use MySQLConfigFile, then UnixAuthentication,
# the SQL server will be asked. If the SQL authentication fails because the
# user wasn't found, another try # will be done with /etc/passwd and
# /etc/shadow. If the SQL authentication fails because the password was wrong,
# the authentication chain stops here. Authentication methods are chained in
# the order they are given.
# 'ls' recursion limits. The first argument is the maximum number of
# files to be displayed. The second one is the max subdirectories depth
# 'ls' 命令的遞歸限制。第一個(gè)參數(shù)給出文件顯示的最大數(shù)目。第二個(gè)參數(shù)給出最大的子目錄深度。
LimitRecursion 10000 8
# Are anonymous users allowed to create new directories ?
# 是否允許匿名用戶創(chuàng)建新目錄
AnonymousCanCreateDirs no
# If the system is more loaded than the following value,
# anonymous users aren't allowed to download.
# 超出負(fù)載后禁止下載
MaxLoad 4
# Port range for passive connections replies. - for firewalling.
# 被動(dòng)模式的端口范圍
# PassivePortRange 30000 50000
# Force an IP address in PASV/EPSV/SPSV replies. - for NAT.
# Symbolic host names are also accepted for gateways with dynamic IP
# addresses.
# 強(qiáng)制一個(gè)IP地址使用被動(dòng)響應(yīng)
# ForcePassiveIP 192.168.0.1
# Upload/download ratio for anonymous users.
# 匿名用戶的上傳/下載的比率
# AnonymousRatio 1 10
# Upload/download ratio for all users.
# This directive superscedes the previous one.
# 所有用戶的上傳/下載的比率
# UserRatio 1 10
# Disallow downloading of files owned by "ftp", ie.
# files that were uploaded but not validated by a local admin.
# 禁止下載匿名用戶上傳但未經(jīng)驗(yàn)證的文件
AntiWarez yes
# IP address/port to listen to (default=all IP and port 21).
# 服務(wù)監(jiān)聽(tīng)的IP 地址和端口。(默認(rèn)是所有IP地址和21端口)
# Bind 127.0.0.1,21
# Maximum bandwidth for anonymous users in KB/s
# 匿名用戶帶寬限制(KB)
# AnonymousBandwidth 8
# Maximum bandwidth for *all* users (including anonymous) in KB/s
# Use AnonymousBandwidth *or* UserBandwidth, both makes no sense.
# 所有用戶的最大帶寬(KB/s),包括匿名用戶。
UserBandwidth 1024
# File creation mask. <umask for files>:<umask for dirs> .
# 177:077 if you feel paranoid.
# 新建目錄及文件的屬性掩碼值
Umask 133:022
# Minimum UID for an authenticated user to log in.
# 認(rèn)證用戶允許登陸的最小組ID(UID)
MinUID 100
# Allow FXP transfers for authenticated users.
# 僅允許認(rèn)證用戶進(jìn)行 FXP 傳輸。
AllowUserFXP no
# Allow anonymous FXP for anonymous and non-anonymous users.
# 對(duì)匿名用戶和非匿名用戶允許進(jìn)行匿名 FXP 傳輸
AllowAnonymousFXP no
# Users can't delete/write files beginning with a dot ('.')
# even if they own them. If TrustedGID is enabled, this group
# will have access to dot-files, though.
# 不能刪除/寫(xiě)入隱藏文件
ProhibitDotFilesWrite no
# Prohibit *reading* of files beginning with a dot (.history, .ssh...)
# 禁止讀取隱藏文件
ProhibitDotFilesRead no
# Never overwrite files. When a file whose name already exist is uploaded,
# it get automatically renamed to file.1, file.2, file.3, ...
# 有同名文件時(shí)自動(dòng)重新命名
AutoRename no
# Disallow anonymous users to upload new files (no = upload is allowed)
# 不允許匿名用戶上傳文件
AnonymousCantUpload no
# Only connections to this specific IP address are allowed to be
# non-anonymous. You can use this directive to open several public IPs for
# anonymous FTP, and keep a private firewalled IP for remote administration.
# You can also only allow a non-routable local IP (like 10.x.x.x) to
# authenticate, and keep a public anon-only FTP server on another IP.
# 僅允許來(lái)自以下IP地址的非匿名用戶連接。你可以使用這個(gè)指令來(lái)打開(kāi)幾個(gè)公網(wǎng)IP來(lái)提供匿名FTP,
# 而保留一個(gè)私有的防火墻保護(hù)的IP來(lái)進(jìn)行遠(yuǎn)程管理。你還可以只允許一內(nèi)網(wǎng)地址進(jìn)行認(rèn)證,而在另外
# 一個(gè)IP上提供純匿名的FTP服務(wù)。
#
#TrustedIP 10.1.1.1
# If you want to add the PID to every logged line, uncomment the following
# line.
# 如果你要為日志每一行添加 PID 去掉下面行的注釋
#LogPID yes
# Create an additional log file with transfers logged in a Apache-like format :
# fw.c9x.org - jedi [13/Dec/1975:19:36:39] "GET /ftp/linux.tar.bz2" 200 21809338
# This log file can then be processed by www traffic analyzers.
# 使用類(lèi)似于Apache的格式創(chuàng)建一個(gè)額外的日志文件
# AltLog clf:/var/log/pureftpd.log
# Create an additional log file with transfers logged in a format optimized
# for statistic reports.
# 使用優(yōu)化過(guò)的格式為統(tǒng)計(jì)報(bào)告創(chuàng)建一個(gè)額外的日志文件
# AltLog stats:/var/log/pureftpd.log
# Create an additional log file with transfers logged in the standard W3C
# format (compatible with most commercial log analyzers)
# 使用標(biāo)準(zhǔn)的W3C格式創(chuàng)建一個(gè)額外的日志文件
# AltLog w3c:/var/log/pureftpd.log
# Disallow the CHMOD command. Users can't change perms of their files.
# 不接受 CHMOD 命令。用戶不能更改他們文件的屬性
#NoChmod yes
# Allow users to resume and upload files, but *NOT* to delete them.
# 允許用戶恢復(fù)和上傳文件,卻不允許刪除他們
#KeepAllFiles yes
# Automatically create home directories if they are missing
# 用戶主目錄不存在的話,自動(dòng)創(chuàng)建
CreateHomeDir yes
# Enable virtual quotas. The first number is the max number of files.
# The second number is the max size of megabytes.
# So 1000:10 limits every user to 1000 files and 10 Mb.
# 限制用戶可以創(chuàng)建的最大文件數(shù)和用戶空間大小
Quota 10000:10240
# 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
# PID文件位置
#PIDFile /var/run/pure-ftpd.pid
# If your pure-ftpd has been compiled with pure-uploadscript support,
# this will make pure-ftpd write info about new uploads to
# /var/run/pure-ftpd.upload.pipe so pure-uploadscript can read it and
# spawn a script to handle the upload.
# Don't enable this option if you don't actually use pure-uploadscript.
# 如果你的 pure-ftpd 編譯時(shí)加入了 pure-uploadscript 支持,這個(gè)指令將會(huì)使 pure-ftpd
# 發(fā)送關(guān)于新上傳的情況信息到 /var/run/pure-ftpd.upload.pipe,這樣 pure-uploadscript
# 就能讀然后調(diào)用一個(gè)腳本去處理新的上傳
#
#CallUploadScript yes
# This option is useful with servers where anonymous upload is
# allowed. As /var/ftp is in /var, it save some space and protect
# the log files. When the partition is more that X percent full,
# new uploads are disallowed.
# 文件所在磁盤(pán)的最大使用率
MaxDiskUsage 99
# Set to 'yes' if you don't want your users to rename files.
# 是否允許重命名文件(默認(rèn)不允許)
#NoRename yes
# Be 'customer proof' : workaround against common customer mistakes like
# 'chmod 0 public_html', that are valid, but that could cause ignorant
# customers to lock their files, and then keep your technical support busy
# with silly issues. If you're sure all your users have some basic Unix
# knowledge, this feature is useless. If you're a hosting service, enable it.
# 打開(kāi)以防止用戶犯常識(shí)性錯(cuò)誤
CustomerProof yes
# Per-user concurrency limits. It will only work if the FTP server has
# been compiled with --with-peruserlimits (and this is the case on
# most binary distributions) .
# The format is : <max sessions per user>:<max anonymous sessions>
# For instance, 3:20 means that the same authenticated user can have 3 active
# sessions max. And there are 20 anonymous sessions max.
# 單個(gè)用戶限制:每一個(gè)用戶最大允許的進(jìn)程;最大的匿名用戶進(jìn)程
# PerUserLimits 3:20
# When a file is uploaded and there is already a previous version of the file
# with the same name, the old file will neither get removed nor truncated.
# Upload will take place in a temporary file and once the upload is complete,
# the switch to the new version will be atomic. For instance, when a large PHP
# script is being uploaded, the web server will still serve the old version and
# immediatly switch to the new one as soon as the full file will have been
# transfered. This option is incompatible with virtual quotas.
# NoTruncate yes
# This option can accept three values :
# 0 : disable SSL/TLS encryption layer (default).
# 1 : accept both traditional and encrypted sessions.
# 2 : refuse connections that don't use SSL/TLS security mechanisms,
# including anonymous sessions.
# Do _not_ uncomment this blindly. Be sure that :
# 1) Your server has been compiled with SSL/TLS support (--with-tls),
# 2) A valid certificate is in place,
# 3) Only compatible clients will log in.
# TLS 1
# List of ciphers that will be accepted for SSL/TLS connections
# Prefix with -S: in order to totally disable SSL but not TLS.
# TLSCipherSuite HIGH:MEDIUM:+TLSv1:!SSLv2:+SSLv3
# Listen only to IPv4 addresses in standalone mode (ie. disable IPv6)
# By default, both IPv4 and IPv6 are enabled.
# IPV4Only yes
# Listen only to IPv6 addresses in standalone mode (ie. disable IPv4)
# By default, both IPv4 and IPv6 are enabled.
# IPV6Only yes
# UTF-8 support for file names (RFC 2640)
# Define charset of the server filesystem and optionnally the default charset
# for remote clients if they don't use UTF-8.
# Works only if pure-ftpd has been compiled with --with-rfc2640
# FileSystemCharset big5
# ClientCharset big5