在 Linux 下搭建 Pure-ftpd

文章
林里克斯

Linux 下搭建使用 pure-ftpd 及配置文件详解

实验平台:CentOS 7.6.1810
pure-ftpd版本:1.0.47



一、安装pure-ftpd


  • yum 安装
$ yum install -y epel-release
#需要 epel 源
$ yum install -y pure-ftpd
#yum 安装
  • 源码安装

1.pure-ftpd 官网

https://www.pureftpd.org/project/pure-ftpd/doc/

2.下载源码包

https://download.pureftpd.org/pub/pure-ftpd/releases/
ftp://ftp.pureftpd.org/pub/pure-ftpd/releases/

$ wget https://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.47.tar.gz

$ tar xf pure-ftpd-1.0.47.tar.gz

3../configure --with 参数

$ yum -y install gcc gcc-c++
#需要编译环境

$ ./configure --prefix=/usr/local/pureftpd --without-inetd --with-altlog --with-puredb --with-throttling --with-peruserlimits --with-tls

报错:configure: error: OpenSSL headers not found.
没有 openssl

$ yum -y install openssl openssl-devel
#安装 OpenSSL 依赖
$ ./configure --prefix=/usr/local/pureftpd --without-inetd --with-altlog --with-puredb --with-throttling --with-peruserlimits --with-tls

$ make && make install
安装位置
ls -l /usr/local/pureftpd/
total 0
drwxr-xr-x 2 root root  67 Aug  8 19:31 bin
drwxr-xr-x 2 root root  28 Aug  8 19:31 etc
drwxr-xr-x 2 root root 129 Aug  8 19:31 sbin
drwxr-xr-x 3 root root  17 Aug  8 19:31 share

二、配置文件介绍


1.pure-ftpd 主要文件

$ ls -l /etc/pure-ftpd/
total 32
-rw-r--r--. 1 root root 11479 Aug  8  2020 pure-ftpd.conf      #主配置文件
-rw-r--r--. 1 root root  2009 Aug 19  2017 pureftpd-ldap.conf  #使用到 LDAP 目录的配置文件
-rw-r--r--. 1 root root  3455 Aug 20  2017 pureftpd-mysql.conf #使用到 MySQL 的配置文件
-rw-------. 1 root root   147 Aug  8  2020 pureftpd.passwd     #ftp存放用户,类似 /etc/passwd
-rw-------. 1 root root  2213 Aug  8  2020 pureftpd.pdb        #用户数据库文件
-rw-r--r--. 1 root root  2976 Aug 20  2017 pureftpd-pgsql.conf #使用到 pgsql 的配置文件

2.pure-ftpd.conf

############################################################
#                                                          #
#         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
# 最大的客户端数量
MaxClientsNumber            50

# Fork in background
# 后台运行
Daemonize                   yes

# Maximum number of sim clients with the same IP address
# 每个ip最大连接数
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.
# 只允许匿名用户访问
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.
# 设置日志的告警级别,默认为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.
# 是否在日志文件中进行主机名解析,不进行客户端DNS解析
DontResolve                 yes

# Maximum idle time in minutes (default = 15 minutes)
# 最大空闲时间
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 用户数据库路径
 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 认证方式, 去掉下面行的注释
# PAMAuthentication             yes

# If you want simple Unix (/etc/passwd) authentication, uncomment this
# 如果你要启用 简单的 Unix系统 认证方式(/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' 命令的递归限制。第一个参数给出文件显示的最大数目。第二个参数给出最大的子目录深度。
LimitRecursion              10000 8

# Are anonymous users allowed to create new directories ?
# 是否允许匿名用户创建新目录
AnonymousCanCreateDirs      no

# If the system is more loaded than the following value,
# anonymous users aren't allowed to download.
# 超出负载后禁止下载
MaxLoad                     4

# Port range for passive connections replies. - for firewalling.
# 被动模式的端口范围
# 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.
# 强制一个IP地址使用被动响应
# 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.
# 禁止下载匿名用户上传但未经验证的文件
AntiWarez                   yes

# IP address/port to listen to (default=all IP and port 21).
# 服务监听的IP 地址和端口。(默认是所有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.
# 认证用户允许登陆的最小组ID(UID) 
MinUID                      100

# Allow FXP transfers for authenticated users.
# 仅允许认证用户进行 FXP 传输。
AllowUserFXP                no

# Allow anonymous FXP for anonymous and non-anonymous users.
# 对匿名用户和非匿名用户允许进行匿名 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.
# 不能删除/写入隐藏文件
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, ...
# 有同名文件时自动重新命名
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.
# 仅允许来自以下IP地址的非匿名用户连接。你可以使用这个指令来打开几个公网IP来提供匿名FTP,
# 而保留一个私有的防火墙保护的IP来进行远程管理。你还可以只允许一内网地址进行认证,而在另外
# 一个IP上提供纯匿名的FTP服务。
#
#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.
# 使用类似于Apache的格式创建一个额外的日志文件
# AltLog                     clf:/var/log/pureftpd.log

# Create an additional log file with transfers logged in a format optimized
# for statistic reports.
# 使用优化过的格式为统计报告创建一个额外的日志文件
# 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)
# 使用标准的W3C格式创建一个额外的日志文件
# 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.
# 允许用户恢复和上传文件,却不允许删除他们
#KeepAllFiles                yes

# Automatically create home directories if they are missing
# 用户主目录不存在的话,自动创建
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.
# 限制用户可以创建的最大文件数和用户空间大小
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 编译时加入了 pure-uploadscript 支持,这个指令将会使 pure-ftpd
# 发送关于新上传的情况信息到 /var/run/pure-ftpd.upload.pipe,这样 pure-uploadscript
# 就能读然后调用一个脚本去处理新的上传
#
#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.
# 文件所在磁盘的最大使用率
MaxDiskUsage               99

# Set to 'yes' if you don't want your users to rename files.
# 是否允许重命名文件(默认不允许)
#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.
# 打开以防止用户犯常识性错误
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.
# 单个用户限制:每一个用户最大允许的进程;最大的匿名用户进程
# 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

3.--with

--with-altlog:除了 syslog 输出外,还支持以其他格式登录到特定文件。当前,CLF,Stats,W3C和xferlog格式已实现。
CLF(通用日志格式)是 Apache,WebFS,Roxen 和大多数Web服务器生成的基本格式。这些日志文件仅记录文件传输,它们可以提供Web统计软件(Analog,Webalizer等)以分析FTP服务器的负载。Stats格式是一种特殊的输出格式,专门用于日志文件分析软件。W3C格式是大多数商用日志分析器解析的标准格式(所有支持IIS的分析器都应处理它)。Xferlog是wu-ftpd创建的传统格式。请在本文档后面的-O 选项中查看其他信息。

--with-brokenrealpath:某些Solaris版本的realpath()实现已损坏。如果altlog和/或pure-uploadscript 
在您的系统上似乎无法正常工作,请尝试使用此开关重新编译。

--with-tls:启用TLS支持

--with-certfile = <文件>:带有TLS证书的文件。在默认情况下是 /etc/ssl/private/pure-ftpd.pem。

--with-cookie:当用户登录时显示财富或自定义横幅

--with-diraliases:支持目录别名(“快捷方式”为“ cd”命令)

--with-everything:构建一台大型服务器,并启用几乎所有功能:altlog,cookie,限制,比率,ftpwho,上传脚本,虚拟用户(puredb),配额,虚拟主机,目录别名,外部身份验证,Bonjour和特权分离。

--with-extauth:编译对外部身份验证模块的支持。

--with-ftpwho:支持'pure-ftpwho'命令。启用此功能需要一些额外的内存。当服务器独立运行时更好地使用它模式。在inetd模式下,它可能会变慢。

--with-language=english     英语
--with-language=albanian    阿尔巴尼亚
--with-language=german      德语
--with-language=romanian    罗马尼亚语
--with-language=french      法语
--with-language=polish      抛光
--with-language=spanish     西班牙语
--with-language=danish      丹麦语
--with-language=italian     意大利语
--with-language=brazilian-portuguese    巴西葡萄牙语
--with-language=slovak      斯洛伐克语
--with-language=dutch       荷兰语
--with-language=korean      韩语
--with-language=swedish     瑞典语
--with-language=norwegian   挪威语
--with-language=russian     俄语
--with-language=traditional-chinese     繁体中文
--with-language=simplified-chinese      简体中文
--with-language=hungarian   匈牙利语
--with-language=catalan     加泰罗尼亚语
--with-language=czech       捷克语
更改服务器消息的语言。默认为英语

--with-ldap:使用本机LDAP目录支持。启用此选项后,可以绕过系统帐户。您需要 OpenLDAP 才能使用该功能。如果OpenLDAP安装在自定义位置,则可以使用--with-ldap = <directory>语法

--with-minimal:为了有效利用现代FTP客户端的功能,Pure-FTPd 实现了FTP协议的基础,并具有许多扩展名(SITE IDLE,网站CHMOD,MLSD,...)。使用--with-minimal指令,将不会在其中编译这些扩展。
此外,将没有独立的服务器,没有用户名/组名的查询,没有幽默和ASCII支持。但是可执行文件的大小将小于默认安装的大小。您至少需要GCC 3.3才能使用此选项进行编译。正则表达式将被编译。
如果仍想减小大小,请结合使用 --without-globbing 和 --with-minimal。如果要构建嵌入式系统,请使用它。在所有其他情况下,为避免引起客户的投诉(尤其是Windows客户端),请忽略此操作。

--with-mysql:对用户数据库使用本地MySQL支持。当这个选项启用后,可以绕过系统帐户。应该安装MySQL客户端库以使用该功能。如果MySQL安装在自定义位置,则可以使用--with-mysql = <directory>语法。

--with-nonroot:设置不需要启动root特权的服务器。任何普通用户都可以运行服务器。如果对非专用托管服务器具有有限的外壳访问权限,则该功能很有用。但是某些功能被禁用,并且只能通过LDAP,SQL或PureDB来检查密码。启用虚拟chroot时,人员将被限制在服务器启动所在的目录中。这是一种不安全的模式,专门用于设置普通(非root)用户使用的非常临时的服务器。默认情况下,将在独立模式下侦听端口21 。如果要使用非root用户模式,则必须编译并“安装”该软件(./configure --prefix = ... && make install-strip)。/sbin,/bin 和 /man 目录将在该前缀中创建。但是,您还必须添加 /etc目录(用户pure-ftpd可以读写运行)。可以
通过名为FTP_ANON_DIR的环境变量来更改匿名FTP根目录。

--with-pam:使用可插入身份验证模块。如果您的登录名/密码对始终被拒绝,则不要使用此选项(但真正的解决方法是修复您的PAM配置)。您需要创建 /etc/pam.d/pure-ftpd 文件才能正确使用PAM身份验证。“ pam”目录包含此类文件的示例。

--with-paranoidmsg:偏执狂消息比sysadmin友好消息更受青睐。启用此选项后,无论问题的根源如何,登录失败都将向用户显示相同的消息。如果没有此选项,则在出现密码问题时会显示“身份验证失败” ,而在sysadmin禁止用户时会显示“对不起,我不能信任您” 。

--with-peruserlimits:启用每个用户的并发限制。在负载非常大的服务器上避免这种情况。

--with-pgsql:对用户数据库使用本机Postgres支持。启用此选项后,可以绕过系统帐户。应该安装Postgres客户端库以使用该功能。如果Postgres安装在自定义位置,则可以使用--with-pgsql = <directory>语法。

--with-probe-random-dev:Pure-FTPd使用 /dev/urandom 或 /dev/random 设备提供难以预测的随机数。这些设备的存在通常在编译时进行探测。如果要在主机上编译二进制程序包,然后在其他主机上运行它,则此选项将在以下位置启用探测运行。这在 Linux 和 BSD 系统上没有用,但在 Solaris和 QNX 上可能需要。

--with-puredb:支持虚拟用户,即。一个本地用户数据库,独立于您的系统帐户。

--with-quotas:启用虚拟配额。使用虚拟配额,可以限制用户可以在其帐户中存储的最大文件数。当然,也可以限制总大小。

--with-ratios:支持上载/下载比率。

--with-sysquotas:支持系统配额(不支持Pure-FTPd的虚拟配额)。

--with-throttling:支持带宽限制(见下文)。

--with-uploadscript:从0.98开始,Pure-FTPd在上传方面具有不错的功能。成功上传后,可以自动调用任何外部程序或脚本。它需要另一个由 Pure-FTPd 软件包安装的程序,称为“ pure-uploadscript”。

--with-virtualchroot:通常,当用户被chroot(-A和-a 选项)时,不可能退出其主目录。启用该功能可以实现:即使符号链接指向不在用户主目录中的目录,也始终遵循它们。这个对于具有共享目录非常有用(例如,在每个主目录中都有一个指向 /var/incoming 的符号链接)。
默认情况下未启用此功能。

--with-virtualhosts:支持虚拟主机。这意味着可以为每个 IP 地址使用不同的匿名 FTP 区域。如果服务器只有一个IP地址,则不需要该功能。但是,如果您有多个 IP 地址,并且希望连接到IP xxx 的客户端获取 /etc/pure-ftpd/xxx/ 而不是 ~ftp/ 的内容。

--with-welcomemsg:读取“ welcome.msg”文件以与某些文件兼容其他FTP服务器。这是一个安全漏洞(匿名用户可以上载“ welcome.msg”文件以添加随机横幅)。Pure-ftpd 默认使用'.banner'文件。

--with-boring:显示无聊的“专业外观”消息。

--with-bonjour:在MacOS X上启用Bonjour支持(请参阅-v开关)。

--with-rfc2640:启用对字符集转换的支持。它增加了对iconv库的依赖,并且需要更多的CPU时间。

--with-implicittls:构建一个FTPS服务器(隐式启用TLS)。该协议与FTP不兼容,默认情况下侦听另一个端口(端口990,ftps)。除非您知道自己在做什么,否则切勿启用此选项。

4.--without

--without-privsep:禁用特权分离(请参阅稍后的注释),不建议这样做。

--without-ascii:不支持7位传输(ASCII)。如果有使用 Windows 客户端发送脚本和 HTML 文件的客户,请不要使用此选项。

--without-capabilities:如果找到了功能库(libcap),Pure-FTPd 将尝试使用它来增强安全性。此选项将覆盖测试以忽略库。如果功能在系统上无法正常工作,请尝试此操作。可以从 ftp://ftp.kernel.org/pub/linux/libs/security/linux-privs/ 下载libcap 。

--without-globbing:不包含全局代码。它减少了内存占用,但正则表达式不再起作用(如'ls *.rpm'之类的东西)。

--without-humor:如果在不查看源代码的情况下找到此选项的功能

--without-inetd:如果将始终以独立模式运行 Pure-FTPd,则启用此标志可以节省一些代码字节。不要启用 --without-inetd 和 --without-standalone,因为没有其中一个就无法运行服务器。这些选项在 Pure-FTPd 的二进制发行版中未启用,因此支持 inetd-like 和独立模式。

--without-iplogging:请勿记录任何IP地址以保护机密性,尤其是对于政治服务器。

--without-nonalnum:偏执文件名检查:仅允许基本字母数字字符。切勿盲目启用此开关,否则客户端会抱怨。

--without-unicode:禁止非拉丁字符。如果文件名中没有特殊字符,则推荐使用。

--without-sendfile:在Linux,Solaris,HPUX和FreeBSD内核上,Pure-FTPd 尝试通过使用特殊的系统调用(sendfile)来减少CPU /内存的使用。它在大多数文件系统中都可以很好地工作。但是,此优化未在当前内核中的所有文件系统上实现。

--without-shadow:即使自动检测到影子密码,也请忽略它们。除非您使用PAM,LDAP或SQL,否则通常是个坏主意。纯FTPd支持影子密码的有效期(包括帐户和密码)。

--without-standalone:FTP服务器通常可以以独立模式运行(没有任何超级服务器)。如果不需要该功能,并且想节省几个代码字节,请添加此选项。必须运行 xinetd 或 tcpserver 之类的超级服务器才能运行该服务。但是推荐使用独立模式。

--without-usernames:从不在目录列表中输出用户名和组名,仅输出UID和GID。它可以提高安全性和性能,但是有些人认为这不方便使用。

5.命令介绍

配置虚拟用户命令:
pure-pw useradd     #新增用户
-u      #uid
-g      #gid
-D/-d   #指定目录
-c      #
-t      #下载带宽
-T      #上传带宽
-n      #最大文件数
-N      #最大大小(单位MB)
-q      #上传比率
-Q      #上传比率
-r      #允许客户端IP
-R      #拒绝客户端IP
-i      #允许本地IP
-I      #拒绝本地IP
-y      #最大并发数
-z      #
pure-pw usermod     #修改用户
pure-pw userdel     #删除用户
pure-pw passwd      #修改密码
pure-pw show        #查看用户信息
pure-pw mkdb        #生成用户数据库文件
pure-pw list        #查看用户列表

三、实战


1.启动

$ systemctl enable pure-ftpd
$ systemctl start pure-ftpd

2.定义数据库文件

$ vim /etc/pure-ftpd/pure-ftpd.conf

PureDB                        /etc/pure-ftpd/pureftpd.pdb

3.查看进展和端口

$ ps -ef | grep pure-ftpd
root       7789      1  0 04:01 ?        00:00:00 pure-ftpd (SERVER)
root       7844   7635  0 04:02 pts/0    00:00:00 grep --color=auto pure-ftpd

$ netstat -tlnp | grep 21
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      7789/pure-ftpd (SER 
tcp6       0      0 :::21  

4.创建账号

$ mkdir /home/ftp/
$ pure-pw useradd ftptest -u ftp -d /home/ftp/
Password: 
Enter it again:

$ pure-pw mkdb
#创建用户信息数据库文件

$ pure-pw list
ftptest             /home/ftp/./

$ chown -R ftp. ftp/
$ ls -l /home/
total 0
drwxr-xr-x. 2 ftp ftp 6 Aug  8 04:03 ftp

四、排错


1.用了 1000 id下的账号会有以下报错

$ tail -500f /var/log/meessage

Aug  8 04:39:27 localhost pure-ftpd: (?@127.0.0.1) [INFO] New connection from 127.0.0.1
Aug  8 04:39:28 localhost pure-ftpd: (?@127.0.0.1) [WARNING] Can't login as [ftptest]: account disabled (uid < 1000)
Aug  8 04:39:30 localhost pure-ftpd: (?@127.0.0.1) [INFO] Logout.

解决报错:

1.编辑 pure-ftpd 配置文件
$ pure-pw list
ftptest             /home/ftp/./  

$ pure-pw show ftptest

Login              : ftptest
Password           : $6$k64DmfFswgG1Mdc0$hh8PGsscO4bVPsFRZYE50sBU5C6hX9/DO6A963KMviXcuyFgorKdLVzDAd3ijk2VRu7NsNuGpajTy3fitxUOE1
UID                : 14 (ftp)
GID                : 50 (ftp)
Directory          : /home/ftp/./

$ vim /etc/pure-ftpd/pure-ftpd.conf
MinUID                      10
#UID 是 14,写 14 以下数字即可,写 0 表示 root 也可

2.重创账号
$ useradd ftpuser -u 1001 -d /home/ftp/ -s /usr/sbin/nologin
$ chown -R ftpuser. /home/ftp/
$ pure-pw useradd -u ftpuser -d /home/ftpuser

Over~

版权协议须知!

本篇文章来源于 Uambiguous ,如本文章侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意

991 0 2020-08-08


分享:
icon_mrgreen.gificon_neutral.gificon_twisted.gificon_arrow.gificon_eek.gificon_smile.gificon_confused.gificon_cool.gificon_evil.gificon_biggrin.gificon_idea.gificon_redface.gificon_razz.gificon_rolleyes.gificon_wink.gificon_cry.gificon_surprised.gificon_lol.gificon_mad.gificon_sad.gificon_exclaim.gificon_question.gif
博主卡片
林里克斯 博主大人
一个致力于Linux的运维平台
运维时间
搭建这个平台,只为分享及记载自己所遇之事和难题。

现在时间 2024-05-18

今日天气
站点统计
  • 文章总数:240篇
  • 分类总数:29个
  • 评论总数:10条
  • 本站总访问量 222809 次

@奥奥

@Wong arrhenius 牛比

@MakerFace 厉害了!