與 Fritzbox NAS 的 FTPS 連線失敗 - 由於 EPSV / PAS 連接埠變更?

與 Fritzbox NAS 的 FTPS 連線失敗 - 由於 EPSV / PAS 連接埠變更?

我使用連接 USB HDD 的 FRITZ!Box 3490 作為 NAS 伺服器。我已經配置了某個連接埠(32753)用於FTP通訊。為了確保靜態伺服器名稱(u*********u.myfritz.net),我啟動並配置了 myFritz。

當我透過 WinSCP 從我的(非本地連接的)筆記型電腦存取 NAS 時,存取 NAS 工作正常。

但是,當我嘗試透過我的網路空間的遠端伺服器存取 NAS 時,在執行 EPSV 或 PAS 命令後連線失敗。

這是終端:

$ curl -v --ftp-pasv --ssl -k -u speedITBackup 'ftp://u**********u.myfritz.net:32753/Backup/Superfein/'
Enter host password for user 'speedITBackup':
*   Trying 92.218.125.113...
* TCP_NODELAY set
* Connected to u**********u.myfritz.net (92.218.125.113) port 32753 (#0)
< 220 FRITZ!Box3490 FTP server ready.
> AUTH SSL
< 501 Use AUTH TLS for secure control connection.
> AUTH TLS
< 234 Authentication method accepted
* successfully set certificate verify locations:
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, [no content] (0):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, [no content] (0):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, [no content] (0):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, [no content] (0):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, [no content] (0):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* Server certificate:
*  subject: CN=u************u.myfritz.net
*  start date: Dec  9 12:27:41 2022 GMT
*  expire date: Jan 15 12:27:41 2038 GMT
*  issuer: CN=u**********u.myfritz.net
*  SSL certificate verify result: self signed certificate (18), continuing anyway.
* TLSv1.3 (OUT), TLS app data, [no content] (0):
> USER speedITBackup
* TLSv1.3 (IN), TLS handshake, [no content] (0):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, [no content] (0):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS app data, [no content] (0):
< 331 Password required for speedITBackup.
* TLSv1.3 (OUT), TLS app data, [no content] (0):
> PASS **************
* TLSv1.3 (IN), TLS app data, [no content] (0):
< 230 User speedITBackup logged in.
* TLSv1.3 (OUT), TLS app data, [no content] (0):
> PBSZ 0
* TLSv1.3 (IN), TLS app data, [no content] (0):
< 200 ok
* TLSv1.3 (OUT), TLS app data, [no content] (0):
> PROT P
* TLSv1.3 (IN), TLS app data, [no content] (0):
< 200 Data channel will be secured
* TLSv1.3 (OUT), TLS app data, [no content] (0):
> PWD
* TLSv1.3 (IN), TLS app data, [no content] (0):
< 257 "/" is current directory.
* Entry path is '/'
* TLSv1.3 (OUT), TLS app data, [no content] (0):
> CWD Backup
* ftp_perform ends with SECONDARY: 0
* TLSv1.3 (IN), TLS app data, [no content] (0):
< 250 CWD command successful.
* TLSv1.3 (OUT), TLS app data, [no content] (0):
> CWD Superfein
* TLSv1.3 (IN), TLS app data, [no content] (0):
< 250 CWD command successful.
* TLSv1.3 (OUT), TLS app data, [no content] (0):
> EPSV
* Connect data stream passively
* TLSv1.3 (IN), TLS app data, [no content] (0):
< 229 Entering Extended Passive Mode (|||60770|)
*   Trying 92.218.125.113...
* TCP_NODELAY set
* Connecting to 92.218.125.113 (92.218.125.113) port 60770
* connect to 92.218.125.113 port 32753 failed: Connection refused
* Failed to connect to u***********u.myfritz.net port 32753: Connection refused
* Failed EPSV attempt. Disabling EPSV
* TLSv1.3 (OUT), TLS app data, [no content] (0):
> PASV
* TLSv1.3 (IN), TLS app data, [no content] (0):
< 227 Entering Passive Mode (92,218,125,113,230,160)
* Skip 92.218.125.113 for data connection, re-use u************u.myfritz.net instead
*   Trying 92.218.125.113...
* TCP_NODELAY set
*** Connecting to 92.218.125.113 (92.218.125.113) port 59040**
* connect to 92.218.125.113 port 32753 failed: Connection refused
* Failed to connect to u**************u.myfritz.net port 32753: Connection refused
* Closing connection 0
* TLSv1.3 (OUT), TLS alert, [no content] (0):
* TLSv1.3 (OUT), TLS alert, close notify (256):
curl: (7) Failed to connect to upfamnsqwzodew4u.myfritz.net Port 32753: Connection refused

我不確定這裡發生了什麼:使用 EPSV 和 PAS 命令,FRITZ!Box 似乎發送一個新連接埠(60770 / 59040),但隨後連接到舊連接埠?

問題出在伺服器端還是客戶端?

有沒有辦法讓這種溝通有效?也許透過我的 FRITZ!Box 設定?

我嘗試使用 cygwin 存取我的 fritzbox,結果是:

$ curl -vvv --ftp-pasv --ssl -k -u speedITBackup 'ftp://u********u.myfritz.net:32753/Backup/Superfein/'
Enter host password for user 'speedITBackup':
*   Trying 92.218.125.113:32753...
* connect to 92.218.125.113 port 32753 failed: Timed out
* Failed to connect to u*************u.myfritz.net port 32753 after 21110 ms: Timed out
* Closing connection 0
curl: (28) Failed to connect to u************u.myfritz.net port 32753 after 21110 ms: Timed out

答案1

我在我的 Android 電視和 fritzbox 3490 上安裝了 x-plore。

突然間,我從 x-plore 到 ftp 連接逾時。有什麼想法為什麼會發生這種情況嗎?我沒有更改任何設定...

答案2

我有一台 FRITZ!Box 7520,並且還運行著一個 FTP 伺服器。我可以從本地 LAN 存取它,也可以從外部存取它。我在 Android 上使用 Total Commander + FTP 外掛程式。我也在使用 myFritz。

FTP 有 3 種類型:

  1. 未加密的 FTP(使用多個連接埠)
  2. FTPS(安全 FTP,使用多個連接埠)
  3. SFTP(基於 SSH 的 FTP,使用一個連接埠)

FRITZ!Box 僅支援 1 和 2。

您的curl 指令正在使用FTPS。它可以連接,但當它嘗試列出檔案時,它會失敗,因為它無法進入被動模式。

此日誌行很可疑:

*** Connecting to 92.218.125.113 (92.218.125.113) port 59040**
* connect to 92.218.125.113 port 32753 failed: Connection refused

它嘗試連接連接埠 59040,然後顯示無法連接連接埠 32753。

請運行:

curl --version

我的是7.74.0。任何接近此版本的版本都是可以接受的。幸運的話你只需要更新curl。

您也可以嘗試以下操作:

  • 在本地區域網路中使用相同的curl命令並查看是否成功。例如,您可以使用 cygwin 讓它在 Windows 上運行。
  • 如果成功,請從外部嘗試
  • 使用wget代替curl

編輯:您在評論中說,您的託管服務商阻止了 49152 和 65534 之間的傳出端口。維基百科。但我不知道僅阻止這些連接埠而允許所有其他連接埠是否有意義。

下面的螢幕截圖顯示了 FRITZ!Box FTP 設定。似乎無法更改被動模式連接埠。只能更改主連接埠。

要解決您的問題,您可以:

  • 切換到另一個主機
  • 使用代理(curl 支援代理)
  • 使用運行 FTP 伺服器的 Raspberry Pi
  • 使用主動模式

在此輸入影像描述

相關內容