无法将文件上传到FTP

时间:2017-04-11 11:42:54

标签: python amazon-web-services ftplib

我一直在尝试将文件上传到AWS EC2实例中的FTP。我为此创建了一个ROOT用户。我收到操作超时错误。以下是我的代码:

    ftp = ftplib.FTP()
    host = "ec2-my-ip.compute-1.amazonaws.com"
    port = 21
    username = 'username'
    password = 'password'
    ftp.connect(host, port)
    print (ftp.getwelcome())
    ftp.login(username, password)
    print 'logged in'
    ftp.cwd("/home/user/")
    print 'changed directory'

    ftp.retrbinary('RETR abc.png', open('/Users/Subhrajyoti/Downloads/abc.png', 'wb').write)
    print 'file transferred'
    ftp.quit()

以下是我得到的输出:

    220 (vsFTPd 2.3.5)
    abc
    changed directory
    [Errno 60] Operation timed out

当我使用filezilla进行连接时,我收到以下错误:

Status:         Resolving address of ec2-my_ip.compute-1.amazonaws.com
Status:         Connecting to my_ip:21...
Status:         Connection established, waiting for welcome message...
Status:         Insecure server, it does not support FTP over TLS.
Status:         Logged in
Status:         Retrieving directory listing...
Command:        PWD
Response:       257 "/home/user"
Command:        TYPE I
Response:       200 Switching to Binary mode.
Command:        PASV
Response:       227 Entering Passive Mode (my,machine,ip,25,4,1).
Command:        LIST
Error:          Connection timed out after 20 seconds of inactivity
Error:          Failed to retrieve directory listing

我已按照python FTPLIB中提供的说明操作。 我做错了什么?

0 个答案:

没有答案