![curl が FTPS へのファイル送信に失敗する](https://rvso.com/image/1157734/curl%20%E3%81%8C%20FTPS%20%E3%81%B8%E3%81%AE%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E9%80%81%E4%BF%A1%E3%81%AB%E5%A4%B1%E6%95%97%E3%81%99%E3%82%8B.png)
「test_file」を FTPS サーバーに送信しようとしています。
curl -v -k --ftp-ssl --tlsv1 --ftp-ssl-reqd --ftp-pasv --key key_nopass.pem --cert client.pem --user 'user:pass' --upload-file test_file ftp://Ftps.example.com:21/
接続はしますが、その後は失敗します。出力は次のようになります。
> * Connected to EXAMPLE.COM_IP_ADDRESS (IP_ADDRESS) port 21 (#0)
> < 220 Microsoft FTP Service
> > AUTH SSL
> < 234 AUTH command ok. Expecting TLS Negotiation.
> * successfully set certificate verify locations:
> USER username
< 331 Password required for username.
> PASS thepassword
< 230 User logged in.
> PBSZ 0
< 200 PBSZ command successful.
> PROT P
< 200 PROT command successful.
> PWD
< 257 "/" is current directory.
* Entry path is '/'
> EPSV
* Connect data stream passively
< 229 Entering Extended Passive Mode (|||5013|)
* Trying example.com.ip.addess
0 0 0 0 0 0 0 0 --:--:-- 0:00:09 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:03:09 --:--:-- 0* Connection timed out
* couldn't connect to host
* got positive EPSV response, but can't connect. Disabling EPSV
> PASV
* response reading failed
0 0 0 0 0 0 0 0 --:--:-- 0:03:09 --:--:-- 0
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
} [data not shown]
curl: (56) response reading failed
「EXAMPLE.COM_IP_ADDRESS (IP_ADDRESS) に接続しました」と「ログインしました」の後に、「ホストに接続できませんでした「しかし、上の数行はつながっているようだ」
アップデート: 「--disable-epsv」引数を指定して同じコマンドを実行すると、データ チャネル ポートも開こうとしているようです。
* Connect data stream passively
< 227 Entering Passive Mode (A,B,C,D,19,179).
ここで、A、B、C、D はサーバーの IP で、他の 19,179 はポートだと思います。そうですか? PS: 最後の数字 (179) は、コマンドを実行するたびに 1 ずつ増加します。