我在Debian框中安装了vsFTP.使用ftp命令手动上传文件时,没关系.即,以下会话工作:
john@myhost:~$ ftp xxx.xxx.xxx.xxx 5111 Connected to xxx.xxx.xxx.xxx. 220 Hello,Welcom to my FTP server. Name (xxx.xxx.xxx.xxx:john): ftpuser 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> put st.zip local: st.zip remote: st.zip 200 PORT command successful. Consider using PASV. 150 Ok to send data. 226 File receive OK. 12773 bytes sent in 0.00 secs (277191.8 kB/s) ftp> 221 Goodbye.
(请注意,如上所述,我将vsFTP服务器配置为使用非默认端口,例如5111由于某种原因)
现在,当我在python中编写脚本以编程方式上传文件时,它失败了.错误显示'超时',如下面的会话所示:
john@myhost:~$ ipython Python 2.5.2 (r252:60911, Jan 24 …
我在AWS EC2(Ubuntu16.04)上使用被动模式(PASV)设置了FTP服务器,但它不起作用.但是,它适用EPSV,不知道为什么.我四处搜索但没有找到答案,任何人都可以帮我这个吗?
1. vsftpd配置
anonymous_enable=NO
local_enable=YES
write_enable=YES
chroot_local_user=YES
pasv_enable=YES
pasv_min_port=13000
pasv_max_port=13100
port_enable=YES
pasv_address=[public ip address of AWS EC2 instance]
allow_writeable_chroot=YES
seccomp_sandbox=NO
Run Code Online (Sandbox Code Playgroud)
2. AWS EC2防火墙

3.通过FireFTP进行测试

使用PASV模式,我无法连接到FTP服务器,日志是:
220 (vsFTPd 3.0.3)
USER sensor
331 Please specify the password.
PASS (password not shown)
230 Login successful.
CWD /
250 Directory successfully changed.
TYPE A
200 Switching to ASCII mode.
PASV
QUIT
Run Code Online (Sandbox Code Playgroud)
但是,使用它EPSV(选择了IPV6复选框),日志如下:
220 (vsFTPd 3.0.3)
USER sensor
331 Please specify the password.
PASS (password not …Run Code Online (Sandbox Code Playgroud) 我正在尝试连接到 FTP,但无法运行任何命令。
ftp_server = ip
ftp_username = username
ftp_password = password
ftp = ftplib.FTP(ftp_server)
ftp.login(ftp_username, ftp_password)
'230 Logged on'
ftp.nlst()
Run Code Online (Sandbox Code Playgroud)
将ftp.nlst引发此错误:
错误:
[WinError 10060] 连接尝试失败,因为连接方在一段时间后没有正确响应,或者因为连接的主机没有响应而建立连接失败
我已经使用 FileZilla(在同一台机器上运行)测试了连接,它工作正常。
这是 FileZilla 日志:
ftp_server = ip
ftp_username = username
ftp_password = password
ftp = ftplib.FTP(ftp_server)
ftp.login(ftp_username, ftp_password)
'230 Logged on'
ftp.nlst()
Run Code Online (Sandbox Code Playgroud)