1. 现象及原因
VScode的SFTP插件,配置好之后,不管上传还是下载,都一直在转圈,无法正常使用。打开插件的debug后得到以下日志:
[07-03 15:40:15] [trace] run command 'Download File'
[07-03 15:40:15] [trace] handle download file for d:\abc.json
[07-03 15:40:15] [debug] > USER abc
[07-03 15:40:15] [debug] < '331 User abc OK. Password required\r\n'
[07-03 15:40:15] [debug] > PASS ******
[07-03 15:40:20] [debug] < '230 OK. Current directory is /\r\n'
[07-03 15:40:20] [debug] > FEAT
[07-03 15:40:20] [debug] > TYPE I
[07-03 15:40:20] [debug] < '200 TYPE is now 8-bit binary\r\n'
[07-03 15:40:20] [debug] > PASV
[07-03 15:40:20] [debug] < '227 Entering Passive Mode (172,11,182,45,154,234)\r\n'
[07-03 15:40:30] [debug] > NOOP
[07-03 15:40:30] [debug] < '200 Zzz...\r\n'
[07-03 15:40:40] [debug] > ABOR
[07-03 15:40:40] [debug] < "226 Since you see this ABOR must've succeeded\r\n"
关键日志是:
[07-03 15:40:20] [debug] > PASV
[07-03 15:40:20] [debug] < '227 Entering Passive Mode (172,11,182,45,154,234)\r\n'
被动模式返回的172.11.182.45
是服务器的内网IP,客户端根本就连不上,所以就 ABOR 断掉了。
应该是 Pure-Ftpd 默认获取了内网IP作为被动模式连接用的IP,导致客户端无法通过内网IP连接服务器,所以会连接超时。
有时候等个10多秒,文件又能正常上传,是因为SFTP插件在被动模式连接超时后,会自动切换成主动模式。
网友评论