无法使用 Debian FTP 到 Google Compute Engine 实例

Tim*_*gue 2 debian vsftpd

尝试在我的 google 计算引擎实例上设置 vsftpd 后,我无法完全连接到 FTP 服务器。尝试使用 FileZilla 登录后,我收到了以下回复:

Status: Connecting to ***.***.***.***:21...
Status: Connection established, waiting for welcome message...
Response:   220 (vsFTPd 2.3.5)
Command:    USER anonymous
Response:   331 Please specify the password.
Command:    PASS **************
Response:   230 Login successful.
Command:    SYST
Response:   215 UNIX Type: L8
Command:    FEAT
Response:   211-Features:
Response:    EPRT
Response:    EPSV
Response:    MDTM
Response:    PASV
Response:    REST STREAM
Response:    SIZE
Response:    TVFS
Response:    UTF8
Response:   211 End
Command:    OPTS UTF8 ON
Response:   200 Always in UTF8 mode.
Status: Connected
Status: Retrieving directory listing...
Command:    PWD
Response:   257 "/"
Command:    TYPE I
Response:   200 Switching to Binary mode.
Command:    PASV
Error:  Connection timed out
Error:  Failed to retrieve directory listing
Run Code Online (Sandbox Code Playgroud)

请注意,这是一个全新安装的 vsftpd。

小智 6

解决方法是在配置文件中限制 vsftpd 为 PASV 样式数据连接分配的端口。在 vsftpd.conf 中,添加这两行:

pasv_min_port=12000

pasv_max_port=12100

然后,您需要在 Google Developers Console 中的网络、防火墙规则下打开这些端口(见图)。

在此处输入图片说明

您可能还想添加以下行来覆盖 vsftpd 为响应 PASV 命令而通告的 IP 地址:

pasv_address=xxx.xxx.xxx.xxx

您放置了虚拟机实例的外部 IP。

出于安全原因,我也使用 FTP 端口 211 而不是 21:

监听端口=211