VPS(ovh)にpureftpdをインストールしました。小さなディレクトリを一覧表示できますが(小さいということは、ほんの数個のファイルしかないディレクトリを意味します)、数千のファイル(ディレクトリを含む)がある大きなディレクトリを一覧表示しようとすると、filezillaクライアントに "Unable to"というエラーメッセージが表示されるします。 「ps」ディレクトリをクリックすると、クライアント側でディレクトリリストを検索するというエラーメッセージが表示されます。
Command: USER xxxxx
Response: 331 User xxxxx OK. Password required
Command: PASS ************
Response: 230 OK. Current directory is /
Command: OPTS UTF8 ON
Response: 200 OK, UTF-8 enabled
Status: Connected
Status: Retrieving directory listing...
Command: CWD /ps
Response: 250 OK. Current directory is /ps
Command: TYPE I
Response: 200 TYPE is now 8-bit binary
Command: PASV
Response: 227 Entering Passive Mode (<my_vps_ip>,156,188)
Command: MLSD
Response: 150 Accepted data connection
Response: 226-Options: -a -l
Response: 226 33 matches total
Error: Connection timed out
Error: Failed to retrieve directory listing
コマンドラインでは無限に待ちます。
ftp> cd ps
250 OK. Current directory is /ps
ftp> ls
200 PORT command successful
150 Connecting to port 38359
私はこのルールを読んでサーバーの問題を解決したので、このルールをiptablesに追加しました。
root@vpsxxx:/var/www/html# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp-data ctstate RELATED,ESTABLISHED /* Allow ftp connections on port 20 */
ACCEPT tcp -- anywhere anywhere tcp spts:1024:65535 dpts:1024:65535 ctstate ESTABLISHED /* Allow passive inbound connections */
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp-data ctstate ESTABLISHED /* Allow ftp connections on port 20 */
ACCEPT tcp -- anywhere anywhere tcp spts:1024:65535 dpts:1024:65535 ctstate RELATED,ESTABLISHED /* Allow passive inbound connections */
puretpdにパッシブモードの修正ポート範囲を追加しました。
root@xxx:/var/www/html# cat /etc/pure-ftpd/conf/PassivePortRange
40110 40210
root@xxx:/var/www/html#
リストしたいpsディレクトリの権限は次のとおりです。
drwxr-xr-x 25 root root 4096 May 9 08:29 ps
これは私のクライアントOS(Debian 8)のiptablesです。
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
私が試したことはすべて役に立たず、効果がないようです。 Wiresharkを使用してトラフィックを分析しようとしましたが、FTP-DATAプロトコルパッケージのディレクトリリストの一部を取得しているようですが、問題が発生していますが、何がわかりません...
私はproftpdと同じ問題があることがわかりました。 puretpdを使用する方が良いと思いましたが、そうではありませんでした:)
ベストアンサー1
あなたのコメントを含む問題の説明によると、ファイアウォール(iptables
)はTCPポート20と21との接続をブロックしています。手動FTPを使用しても(受信21は明らかに開いています)、これらの接続が必要です。
詳細については、ファイアウォールブロックのログを検索してください。
dmesg | grep -i firewall | tail -40
ファイルをダウンロードしようとすると失敗します。
さらに、AppArmorやその他のセキュリティ機能により、pureftpd
これらのファイルを提供するプロセスがブロックされる可能性があります。したがって、上記の内容にポートブロックが表示されない場合は、ブロックを解除して問題を解決することができますls -ltr /var/log
。dmesg
grep