非法 PORT 命令。- 通过 WinSCP 连接

非法 PORT 命令。- 通过 WinSCP 连接

当我尝试通过 winscp 连接到我的 ftp 服务器时,第一次出现“非法端口命令”错误,这是在列出根目录 (/) 文件时发生的。我不知道如何摆脱这个错误,一直在检查源脚本(假设有一些初始化脚本),但找不到正确的源或链接来探索。

复制日志上下文以供参考。

仅供参考:FileZilla 运行良好,没有任何问题。请解释一下这个问题!

. 2018-01-08 08:57:09.656 --------------------------------------------------------------------------
. 2018-01-08 08:57:09.656 WinSCP Version 4.2.7 (Build 758) (OS 6.1.7601 Service Pack 1)
. 2018-01-08 08:57:09.656 Login time: Monday, January 08, 2018 8:57:09 AM
. 2018-01-08 08:57:09.656 --------------------------------------------------------------------------
. 2018-01-08 08:57:09.656 Session name: [email protected]
. 2018-01-08 08:57:09.656 Host name: myuploads.com (Port: 21)
. 2018-01-08 08:57:09.656 User name: test (Password: Yes, Key file: No)
. 2018-01-08 08:57:09.656 Tunnel: No
. 2018-01-08 08:57:09.656 Transfer Protocol: FTP
. 2018-01-08 08:57:09.656 Ping type: C, Ping interval: 30 sec; Timeout: 15 sec
. 2018-01-08 08:57:09.656 Proxy: none
. 2018-01-08 08:57:09.656 FTP: FTPS: Explicit TLS; Passive: No [Force IP: No]
. 2018-01-08 08:57:09.656 Local directory: C:\Users\Administrator\Documents, Remote directory: /, Update: Yes, Cache: Yes
. 2018-01-08 08:57:09.656 Cache directory changes: Yes, Permanent: Yes
. 2018-01-08 08:57:09.656 DST mode: 1
. 2018-01-08 08:57:09.656 --------------------------------------------------------------------------
. 2018-01-08 08:57:09.671 Connecting to myuploads.com ...
. 2018-01-08 08:57:09.671 m_pSslLayer changed state from 0 to 1
. 2018-01-08 08:57:09.671 m_pSslLayer changed state from 1 to 2
. 2018-01-08 08:57:09.671 m_pSslLayer changed state from 2 to 4
. 2018-01-08 08:57:09.671 Connected with myuploads.com, negotiating SSL connection...
< 2018-01-08 08:57:09.671 220 (vsFTPd 3.0.2)
> 2018-01-08 08:57:09.671 AUTH TLS
< 2018-01-08 08:57:09.671 234 Proceed with negotiation.
. 2018-01-08 08:57:09.827 SSL_connect: SSLv3 read server hello A
. 2018-01-08 08:57:09.827 SSL_connect: SSLv3 read server certificate A
. 2018-01-08 08:57:09.827 SSL_connect: SSLv3 read server key exchange A
. 2018-01-08 08:57:09.827 SSL_connect: SSLv3 read server certificate request A
. 2018-01-08 08:57:09.827 SSL_connect: SSLv3 read server done A
. 2018-01-08 08:57:09.827 SSL_connect: SSLv3 write client certificate A
. 2018-01-08 08:57:09.827 SSL_connect: SSLv3 write client key exchange A
. 2018-01-08 08:57:09.827 SSL_connect: SSLv3 write change cipher spec A
. 2018-01-08 08:57:09.827 SSL_connect: SSLv3 write finished A
. 2018-01-08 08:57:09.827 SSL_connect: SSLv3 flush data
. 2018-01-08 08:57:09.827 SSL_connect: SSLv3 read finished A
. 2018-01-08 08:57:09.827 Using TLSv1, cipher TLSv1/SSLv3: DHE-RSA-AES256-SHA, 2048 bit RSA
. 2018-01-08 08:57:09.827 SSL connection established. Waiting for welcome message...
> 2018-01-08 08:57:09.827 USER test
< 2018-01-08 08:57:09.827 331 Please specify the password.
> 2018-01-08 08:57:09.827 PASS ******
< 2018-01-08 08:57:09.858 230 Login successful.
> 2018-01-08 08:57:09.952 SYST
< 2018-01-08 08:57:09.952 215 UNIX Type: L8
> 2018-01-08 08:57:09.952 FEAT
< 2018-01-08 08:57:09.952 211-Features:
< 2018-01-08 08:57:09.952  AUTH TLS
< 2018-01-08 08:57:09.952  EPRT
< 2018-01-08 08:57:09.952  EPSV
< 2018-01-08 08:57:09.952  MDTM
< 2018-01-08 08:57:09.952  PASV
< 2018-01-08 08:57:09.952  PBSZ
< 2018-01-08 08:57:09.952  PROT
< 2018-01-08 08:57:09.952  REST STREAM
< 2018-01-08 08:57:09.952  SIZE
< 2018-01-08 08:57:09.952  TVFS
< 2018-01-08 08:57:09.952  UTF8
< 2018-01-08 08:57:09.952 211 End
> 2018-01-08 08:57:09.952 OPTS UTF8 ON
< 2018-01-08 08:57:09.952 200 Always in UTF8 mode.
> 2018-01-08 08:57:09.952 PBSZ 0
< 2018-01-08 08:57:09.952 200 PBSZ set to 0.
> 2018-01-08 08:57:09.952 PROT P
< 2018-01-08 08:57:09.952 200 PROT now Private.
. 2018-01-08 08:57:09.952 Connected
. 2018-01-08 08:57:09.952 Got reply 1 to the command 1
. 2018-01-08 08:57:09.952 --------------------------------------------------------------------------
. 2018-01-08 08:57:09.952 Using FTP protocol.
. 2018-01-08 08:57:09.952 Doing startup conversation with host.
> 2018-01-08 08:57:09.952 PWD
< 2018-01-08 08:57:09.952 257 "/"
. 2018-01-08 08:57:09.952 Got reply 1 to the command 16
. 2018-01-08 08:57:09.952 Changing directory to "/".
> 2018-01-08 08:57:09.952 CWD /
< 2018-01-08 08:57:09.952 250 Directory successfully changed.
. 2018-01-08 08:57:09.952 Got reply 1 to the command 16
. 2018-01-08 08:57:09.952 Getting current directory name.
> 2018-01-08 08:57:09.952 PWD
< 2018-01-08 08:57:09.952 257 "/"
. 2018-01-08 08:57:09.952 Got reply 1 to the command 16
. 2018-01-08 08:57:09.952 Retrieving directory listing...
> 2018-01-08 08:57:09.952 TYPE A
< 2018-01-08 08:57:09.952 200 Switching to ASCII mode.
> 2018-01-08 08:57:09.952 PORT 10,0,40,181,244,221
< 2018-01-08 08:57:09.952 500 Illegal PORT command.
. 2018-01-08 08:57:09.952 Could not retrieve directory listing
. 2018-01-08 08:57:09.952 Got reply 4 to the command 2
. 2018-01-08 08:57:09.968 Retrieving directory listing...
> 2018-01-08 08:57:09.968 TYPE A
< 2018-01-08 08:57:09.968 200 Switching to ASCII mode.
> 2018-01-08 08:57:09.968 PORT 10,0,40,181,244,222
< 2018-01-08 08:57:09.968 500 Illegal PORT command.
. 2018-01-08 08:57:09.968 Could not retrieve directory listing
. 2018-01-08 08:57:09.968 Got reply 4 to the command 2
* 2018-01-08 08:57:09.968 (ECommand) Error listing directory '/'.
* 2018-01-08 08:57:09.968 Could not retrieve directory listing
* 2018-01-08 08:57:09.968 Illegal PORT command.
. 2018-01-08 08:57:27.159 Startup conversation with host finished.
. 2018-01-08 08:57:27.798 Session upkeep
. 2018-01-08 08:57:28.313 Session upkeep

答案1

您已将 WinSCP 配置为使用主动 FTP 模式。

我很确定,您在 FileZilla 中使用了被动模式。

确保在 WinSCP 中重新启用被动模式: https://winscp.net/eng/docs/ui_login_connection

阅读有关 WinSCP 的文章主动/被动模式理解为什么主动模式是一个有问题的模式。

相关内容