当前位置: 首页 > news >正文

debian11 ubuntu24 armbian24 apt install pure-ftpd被动模式的正确配置方法

debian11 ubuntu24 armbian24 apt install pure-ftpd被动模式的正确配置方法

安装方法请看:https://www.itbulu.com/pure-ftpd.html

疑难问题解决

原本以为配置很简单的,无非是修改 ForcePassiveIP MinUID PassivePortRange PureDB这几个配置项就行了,然而问题并不那个简单。

我们先看看原本的配置文件,应该是 /etc/pure-ftpd/pure-ftpd.conf吧,我们来看看里面有啥配置参数。


############################################################
#                                                          #
#             Configuration file for pure-ftpd             #
#                                                          #
############################################################# If you want to run Pure-FTPd with this configuration
# instead of command-line options, please run the
# following command :
#
# ${exec_prefix}/sbin/sbin/pure-ftpd /etc/pure-ftpd/pure-ftpd.conf
#
# Online documentation:
# https://www.pureftpd.org/project/pure-ftpd/doc# Restrict users to their home directoryChrootEveryone               yes# If the previous option is set to "no", members of the following group
# won't be restricted. Others will be. If you don't want chroot()ing anyone,
# just comment out ChrootEveryone and TrustedGID.# TrustedGID                   100# Turn on compatibility hacks for broken clientsBrokenClientsCompatibility   no# Maximum number of simultaneous usersMaxClientsNumber             50# Run as a background processDaemonize                    yes# Maximum number of simultaneous clients with the same IP addressMaxClientsPerIP              8# If you want to log all client commands, set this to "yes".
# This directive can be specified twice to also log server responses.VerboseLog                   no# List dot-files even when the client doesn't send "-a".DisplayDotFiles              yes# Disallow authenticated users - Act only as a public FTP server.AnonymousOnly                no# Disallow anonymous connections. Only accept authenticated users.NoAnonymous                  no# Syslog facility (auth, authpriv, daemon, ftp, security, user, local*)
# The default facility is "ftp". "none" disables logging.SyslogFacility               ftp# Display fortune cookies# FortunesFile                 /usr/share/fortune/zippy# Don't resolve host names in log files. Recommended unless you trust
# reverse host names, and don't care about DNS resolution being possibly slow.DontResolve                  yes# Maximum idle time in minutes (default = 15 minutes)MaxIdleTime                  15# LDAP configuration file (see README.LDAP)# LDAPConfigFile               /etc/pureftpd-ldap.conf# MySQL configuration file (see README.MySQL)# MySQLConfigFile              /etc/pureftpd-mysql.conf# PostgreSQL configuration file (see README.PGSQL)# PGSQLConfigFile              /etc/pureftpd-pgsql.conf# PureDB user database (see README.Virtual-Users)# PureDB                       /etc/pureftpd.pdb# Path to pure-authd socket (see README.Authentication-Modules)# ExtAuth                      /var/run/ftpd.sock# If you want to enable PAM authentication, uncomment the following line# PAMAuthentication            yes# If you want simple Unix (/etc/passwd) authentication, uncomment this# UnixAuthentication           yes# Please note that LDAPConfigFile, MySQLConfigFile, PAMAuthentication and
# UnixAuthentication can be used specified once, but can be combined
# together. For instance, if you use MySQLConfigFile, then UnixAuthentication,
# the SQL server will be used first. If the SQL authentication fails because the
# user wasn't found, a new attempt will be done using system authentication.
# If the SQL authentication fails because the password didn't match, 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.LimitRecursion               10000 8# Are anonymous users allowed to create new directories?AnonymousCanCreateDirs       no# If the system load is greater than the given value, anonymous users
# aren't allowed to download.MaxLoad                      4# Port range for passive connections - keep it as broad as possible.#PassivePortRange             50000 55000# Force an IP address in PASV/EPSV replies. - for NAT.
# Symbolic host names are also accepted for gateways with dynamic IP
# addresses.#ForcePassiveIP                192.168.0.1# Upload/download ratio for anonymous users.# AnonymousRatio               1 10# Upload/download ratio for all users.
# This directive supersedes the previous one.# UserRatio                    1 10# Disallow downloads of files owned by the "ftp" system user;
# files that were uploaded but not validated by a local admin.AntiWarez                    yes# IP address/port to listen to (default=all IP addresses, port 21).# Bind                         127.0.0.1,21# Maximum bandwidth for anonymous users in KB/s# AnonymousBandwidth           8# Maximum bandwidth for *all* users (including anonymous) in KB/s
# Use AnonymousBandwidth *or* UserBandwidth, not both.# UserBandwidth                8# 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.
# For example, a value of 100 prevents all users whose user id is below
# 100 from logging in. If you want "root" to be able to log in, use 0.MinUID                       100# Allow FXP transfers for authenticated users.AllowUserFXP                 no# Allow anonymous FXP for anonymous and non-anonymous users.AllowAnonymousFXP            no# Users can't delete/write files starting with a dot ('.')
# even if they own them. But if TrustedGID is enabled, that group
# will exceptionally have access to dot-files.ProhibitDotFilesWrite        no# Prohibit *reading* of files starting with a dot (.history, .ssh...)ProhibitDotFilesRead         no# Don't overwrite files. When a file whose name already exist is uploaded,
# it gets automatically renamed to file.1, file.2, file.3, ...AutoRename                   no# Prevent anonymous users from uploading 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 (such as 10.x.x.x) for
# authenticated users, and run a public anon-only FTP server on another IP.# TrustedIP                    10.1.1.1# To add the PID to log entries, uncomment the following line.# LogPID                       yes# Create an additional log file with transfers logged in a Apache-like format :
# fw.c9x.org - jedi [13/Apr/2017:19:36:39] "GET /ftp/linux.tar.bz2" 200 21809338
# This log file can then be processed by common HTTP traffic analyzers.# 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 many HTTP log analyzers)# AltLog                       w3c:/var/log/pureftpd.log# Disallow the CHMOD command. Users cannot change perms of their own files.# NoChmod                      yes# Allow users to resume/upload files, but *NOT* to delete them.# KeepAllFiles                 yes# Automatically create home directories if they are missing# CreateHomeDir                yes# Enable virtual quotas. The first value is the max number of files.
# The second value is the maximum size, in megabytes.
# So 1000:10 limits every user to 1000 files and 10 MB.# Quota                        1000:10# 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# 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.# CallUploadScript             yes# This option is useful on servers where anonymous upload is
# allowed. When the partition is more that percententage full,
# new uploads are disallowed.MaxDiskUsage                   99# Set to 'yes' to prevent users from renaming files.# NoRename                     yes# Be 'customer proof': forbids common customer mistakes such as
# 'chmod 0 public_html', that are valid, but can cause customers to
# unintentionally shoot themselves in the foot.CustomerProof                yes# Per-user concurrency limits. Will only work if the FTP server has
# been compiled with --with-peruserlimits.
# Format is: <max sessions per user>:<max anonymous sessions>
# For example, 3:20 means that an authenticated user can have up to 3 active
# sessions, and that up to 20 anonymous sessions are allowed.# PerUserLimits                3:20# When a file is uploaded and there was already a previous version of the file
# with the same name, the old file will neither get removed nor truncated.
# The file will be stored under a temporary name and once the upload is
# complete, it will be atomically renamed. For example, when a large PHP
# script is being uploaded, the web server will keep serving the old version and
# later switch to the new one as soon as the full file will have been
# transferred. This option is incompatible with virtual quotas.# NoTruncate                   yes# This option accepts three values:
# 0: disable SSL/TLS encryption layer (default).
# 1: accept both cleartext and encrypted sessions.
# 2: refuse connections that don't use the TLS security mechanism,
#    including anonymous sessions.
# Do _not_ uncomment this blindly. Double check that:
# 1) The server has been compiled with TLS support (--with-tls),
# 2) A valid certificate is in place,
# 3) Only compatible clients will log in.# TLS                          1# Cipher suite for TLS sessions.
# The default suite is secure and setting this property is usually
# only required to *lower* the security to cope with legacy clients.
# Prefix with -C: in order to require valid client certificates.
# If -C: is used, make sure that clients' public keys are present on
# the server.# TLSCipherSuite               HIGH# Certificate file, for TLS
# The certificate itself and the keys can be bundled into the same
# file or split into two files.
# CertFile is for a cert+key bundle, CertFileAndKey for separate files.
# Use only one of these.# CertFile                     /etc/ssl/private/pure-ftpd.pem
# CertFileAndKey               "/etc/pure-ftpd.pem" "/etc/pure-ftpd.key"# Unix socket of the external certificate handler, for TLS# ExtCert                      /var/run/ftpd-certs.sock# 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 (i.e. disable IPv4)
# By default, both IPv4 and IPv6 are enabled.# IPV6Only                     yes# Append the content of another file, if the file exists.
# If the file doesn't exist, the directive is ignored.
# More files can be recursively included.# Include                      additional_configuration.conf

用被动模式

用systemctl start pure-ftpd

在windows上用winscp连接

报错开始:

监测到超时! (数据连接)
无法获得目录列表
列出'/'的目录项时出错。

这是因为被动端口被防火墙阻止了,配置文件修改以下项PassivePortRange:

# Port range for passive connections - keep it as broad as possible.PassivePortRange             50000 55000

再打开防火墙新入站TCP 端口50000/55000,允许这个端口范围可入。

紧接着,下列表错误一直存在,无法解决

Server sent passive reply with unroutable address 172.16.0.33, using host address instead.
监测到超时! (数据连接)
无法获得目录列表
列出'/'的目录项时出错。

把配置文件中的ForcePassiveIP改成公网的地址58.179.xxx.xxx

# Force an IP address in PASV/EPSV replies. - for NAT.
# Symbolic host names are also accepted for gateways with dynamic IP
# addresses.
ForcePassiveIP                58.179.XXX.XXX

问题依然存在

经过无数次试验,终于发现,/etc/pure-ftpd/pure-ftpd.conf这个配置文件根本没有生效,新的配置项被移动到了 /etc/pure-ftpd/conf/文件夹下。

于是用

echo "50000 55000" > /etc/pure-ftpd/conf/PassivePortRange
echo "58.179.XXX.XXX" > /etc/pure-ftpd/conf/ForcePassiveIP
systemctl restart pure-ftpd 

新建相关配置项文件后,重启,再用winscp连接,终于正常了。

关于ddns,动态公网IP配置

再看看配置说明

# Force an IP address in PASV/EPSV replies. - for NAT.
# Symbolic host names are also accepted for gateways with dynamic IP
# addresses.
ForcePassiveIP                58.179.XXX.XXX

也可以用域名。

echo "www.xxxxx.com" > /etc/pure-ftpd/conf/ForcePassiveIP
systemctl restart pure-ftpd 

如果wan口的地址是动态的,ForcePassiveIP可用动态域名,然后再端口转发21->21及50000/55000到pure-ftpd主机即可。

为什么不用主动模式

区别我就不说了,主动模式在大批量删除或传输数据时会不时中断,亲测被动模式没有这个问题。


文章转载自:

http://jZceeeEX.kwqwp.cn
http://AqVBoW5w.kwqwp.cn
http://Av1WsUwM.kwqwp.cn
http://GtlAt7hM.kwqwp.cn
http://ZGInjMgq.kwqwp.cn
http://6Tj9BLqC.kwqwp.cn
http://HUW73LA4.kwqwp.cn
http://7lwRzolN.kwqwp.cn
http://jLwDyvBu.kwqwp.cn
http://0jEMRSYd.kwqwp.cn
http://CRAX1ufL.kwqwp.cn
http://lzDtaqhQ.kwqwp.cn
http://EEDxFHsG.kwqwp.cn
http://9NM6C1RW.kwqwp.cn
http://DvGwcVOd.kwqwp.cn
http://qHqABBKM.kwqwp.cn
http://5SLhHzuo.kwqwp.cn
http://yB2RJ6TC.kwqwp.cn
http://PamuGYb1.kwqwp.cn
http://XmgfRaF9.kwqwp.cn
http://w11vGiVZ.kwqwp.cn
http://23YoWbqy.kwqwp.cn
http://n5gUNP8y.kwqwp.cn
http://SYU7kttU.kwqwp.cn
http://Afe9egUn.kwqwp.cn
http://hynD2Dx4.kwqwp.cn
http://JiQAcFdw.kwqwp.cn
http://tD57u3d7.kwqwp.cn
http://hdG8KS4c.kwqwp.cn
http://XZbujEJP.kwqwp.cn
http://www.dtcms.com/a/375027.html

相关文章:

  • shell基础(二)
  • LeetCode 24 两两交换链表中的节点( 迭代与递归)
  • 【分布式架构】Dubbo是什么?能做什么?
  • n1 ARMbian部署Grafana
  • SpringBoot后端基础案例
  • Shiro概述
  • Nginx 服务用户与防盗链配置
  • NV3041A-01芯片屏幕
  • 《京东商品详情爬取实战指南》
  • MySQL数据库的基础
  • 人工智能机器学习——决策树、异常检测、主成分分析(PCA)
  • 企业使用云服务器租用的优势是什么?
  • docker实践(一)
  • args传参
  • Spring Scheduler定时任务实战:从零掌握任务调度
  • NSGA系列多目标优化算法:从理论到实践
  • 从C++开始的编程生活(7)——取地址运算符重载、类型转换、static成员和友元
  • ArcGIS学习-20 实战-县域水文分析
  • Claude Code 平替:OpenAI发布 Codex CLI ,GPT-5 国内直接使用
  • 技术速递|保护 VS Code 免受提示注入攻击
  • JAVA,IOIOIOIOIOIOIOIOIOIOIOIOIOIO
  • xv6 源码精读(一)环境搭建
  • 基于Golang + vue3 开发的 kafka 多集群管理
  • uniapp微信小程序商品列表数据分页+本地缓存+下拉刷新+图片懒加载
  • OSPF特殊区域、路由汇总及其他特性
  • 后端接口防止XSS漏洞攻击
  • Hadoop(十一)
  • 【Linux基础知识系列:第一百二十五篇】理解Linux中的init与systemd
  • iOS原生开发和Flutter开发的看法
  • 【ArkTS-装饰器】