我在Ubuntu 12.04 LTS中设置了FTP服务器.
现在,当我尝试通过命令行从Windows 7连接到FTP服务器时ftp.exe,我成功连接但我无法获取目录列表.我收到错误
200 PORT command successful. Consider using PASV.
425 Failed to establish connection.
Run Code Online (Sandbox Code Playgroud)
Sha*_*non 12
使用passive前请尝试使用该命令ls.
从FTP客户端,检查FTP服务器是否支持被动模式,登录后输入quote PASV.
以下是带有被动模式的vsftpd服务器的连接示例
vsftpd用pasv_enable=NO:
# ftp localhost
Connected to localhost.localdomain.
220 (vsFTPd 2.3.5)
Name (localhost:john): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> quote PASV
550 Permission denied.
ftp>
Run Code Online (Sandbox Code Playgroud)
vsftpd用pasv_enable=YES:
# ftp localhost
Connected to localhost.localdomain.
220 (vsFTPd 2.3.5)
Name (localhost:john): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> quote PASV
227 Entering Passive Mode (127,0,0,1,173,104).
ftp>
Run Code Online (Sandbox Code Playgroud)
Mar*_*ryl 12
您正在以活动模式使用FTP.
由于防火墙和NAT,现在在活动模式下设置FTP可能很麻烦.
可能是因为您的本地防火墙或NAT,服务器无法连接回客户端以建立数据传输连接.
或者您的客户端不知道其外部IP地址,而是向服务器(在PORT命令中)提供内部地址,服务器显然无法使用该地址.但情况并非如此,因为vsftpd默认拒绝数据传输地址与FTP控制连接的源地址(port_promiscuous指令)不同.
请参阅我的文章活动模式的网络配置.
如果可能,您应该使用被动模式,因为它通常不需要在客户端进行额外设置.这也是服务器通过"考虑使用PASV"向您建议的内容.这PASV是一个用于进入被动模式的FTP命令.
不幸的是,Windows FTP命令行客户端(ftp.exe)根本不支持被动模式.它现在变得毫无用处.
请改用其他第三方Windows FTP命令行客户端.大多数其他人支持被动模式.
例如,WinSCP FTP客户端默认为被动模式,并且有一个指南可用于将Windows FTP脚本转换为WinSCP脚本.
(我是WinSCP的作者)
您需要使用被动模式。
如果您使用的是 linux 客户端,请使用pftp或ftp -p。
来自man ftp:
-p Use passive mode for data transfers. Allows use of ftp in environments where a firewall prevents connections from the outside world back to the client machine. Requires that the ftp server support the PASV command. This is the default if invoked as pftp.
Run Code Online (Sandbox Code Playgroud)
小智 6
实际上,您的窗口防火墙阻止了连接,因此您需要从管理员将这些命令输入cmd.exe。
1) netsh advfirewall firewall add rule name="FTP" dir=in action=allow program=%SystemRoot%\System32\ftp.exe enable=yes protocol=tcp
2) netsh advfirewall firewall add rule name="FTP" dir=in action=allow program=%SystemRoot%\System32\ftp.exe enable=yes protocol=udp
如果万一出问题了,您可以通过以下方式恢复:
1) netsh advfirewall firewall delete rule name="FTP" program=%SystemRoot%\System32\ftp.exe
| 归档时间: |
|
| 查看次数: |
89661 次 |
| 最近记录: |