pure-ftpd 在 TLS 模式下为被动连接提供错误 IP

pure-ftpd 在 TLS 模式下为被动连接提供错误 IP

我正在设置我们的 ftp 服务器 ( pure-ftpd-1.0.21-r1 ) 以使用 TLS/SSL。当我不使用 TLS 时,它可以工作。

从命令选项开始:

-S 21 -c 30 -C 10 -B -k 90% -A -R -Z -p 49152:65534 -U 013 -s --tls=1

Response:   230 OK. Current restricted directory is /
Command:    SYST
Response:   215 UNIX Type: L8
Command:    FEAT
Response:   211-Extensions supported:
Response:    EPRT
Response:    IDLE
Response:    MDTM
Response:    SIZE
Response:    REST STREAM
Response:    MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
Response:    MLSD
Response:    TVFS
Response:    ESTP
Response:    PASV
Response:    EPSV
Response:    SPSV
Response:    ESTA
Response:    AUTH TLS
Response:    PBSZ
Response:    PROT
Response:   211 End.
Status: Connected
Status: Retrieving directory listing...
Command:    PWD
Response:   257 "/" is your current location
Command:    TYPE I
Response:   200 TYPE is now 8-bit binary
Command:    PASV
Response:   227 Entering Passive Mode (76,65,xxx,xxx,228,146) #last octets removed to protect the guilty
Command:    MLSD
Response:   150 Accepted data connection
Response:   226-ASCII
Response:   226-Options: -l 
Response:   226 54 matches total
Status: Directory listing successful
Status: Disconnected from server

当我使用 TLS 时:

Response:   220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
Response:   220-You are user number 4 of 30 allowed.
Response:   220-Local time is now 09:19. Server port: 21.
Response:   220-IPv6 connections are also welcome on this server.
Response:   220 You will be disconnected after 15 minutes of inactivity.
Command:    AUTH TLS
Response:   234 AUTH TLS OK.
Status: Initializing TLS...
Status: Verifying certificate...
Command:    USER john
Status: TLS/SSL connection established.
Response:   331 User john OK. Password required
Command:    PASS ********
Response:   230-User john has group access to:  svn      anonymou proftpd  powercor john    
Response:   230- users    usb      ftp
Response:   230 OK. Current restricted directory is /
Command:    SYST
#....same as above
Response:   200 TYPE is now 8-bit binary
Command:    PASV
Response:   227 Entering Passive Mode (192,168,15,2,198,194)
Status: Server sent passive reply with unroutable address. Using server address instead.
Command:    MLSD
Error:  Connection timed out
Error:  Failed to retrieve directory listing

答案1

我猜想您的 FTP 服务器位于 NAT 防火墙后面,并且防火墙设备上运行着 ip_conntrack_ftp 辅助模块(或等效模块)。基本上,此模块会扫描数据流以查找内部 IP 地址的实例,然后将其重写为外部 IP 地址。但是,对于 TLS 安全的 FTP 连接,它无法执行此操作,因为它无法解密传输中的数据包以查找 IP 地址(通常认为这是一件好事)。

您的选择是:

  • 使用-P选项“强制使用指定的 IP 地址回复 PASV/EPSV/SPSV 命令”。
  • 摆脱 NAT

答案2

您必须在被动命令上指定伪装 IP。

现在你的被动命令返回 192,168,15,2(这是一个私有 IP,无法通过公共互联网连接工作)

  • '-P ':强制使用指定的 IP 地址来回复 PASV/EPSV/SPSV 命令。如果服务器位于无法正确处理状态 FTP 伪装的伪装 (NAT) 框后面,请在此处输入该框的 IP 地址。如果您有动态 IP 地址,则可以输入网关的公共主机名,每次有新客户端连接时都会解析该主机名。

相关内容