美文网首页
VScode的SFTP插件无法连接宝塔的 Pure-Ftpd

VScode的SFTP插件无法连接宝塔的 Pure-Ftpd

作者: 简书是什么书 | 来源:发表于2024-07-02 17:46 被阅读0次

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插件在被动模式连接超时后,会自动切换成主动模式。

2. 解决:手动指定 ForcePassiveIP 的值为公网IP就行

image.png

相关文章

网友评论

      本文标题:VScode的SFTP插件无法连接宝塔的 Pure-Ftpd

      本文链接:https://www.haomeiwen.com/subject/uqovcjtx.html