尝试在python ftp_tls模块中初始化命令时出现eof错误

时间:2019-12-23 11:01:26

标签: python-3.x ssl server ftp tls1.2

我已经从同一托管公司和同一软件包购买了两台服务器, 购买的第一台服务器可以完美运行,这仅用于测试和实验, 支持团队告诉我的另一台服务器,其ssl和ftp版本相同 无效,尝试启动命令时python脚本出现错误。

'''

from ftplib_custom import FTP_TLS
import ssl
import ftplib_custom
import socket

def launch():
#Wait upon user input
print("Press Enter To Initialise Server Connection: ")
input()

#Info
print("Server Found")
print("Admin Auto Login...")
print("\n")

#Connection Initiation

#Working Test Server
ftp = FTP_TLS('MyHostname', user='Username', passwd='Password')

#Not Working Server
ftp = FTP_TLS('MyHostname', user='Username', passwd='Password')

ftp.ssl_version = ssl.PROTOCOL_TLS

print(ftp.getwelcome())
ftp.set_debuglevel(1)
ftp.set_pasv(True)
ftp.prot_p()
ftp.ccc()

print ("Login Successful")

def listLineCallback(line):
    msg = ("** %s*"%line)
    print(msg)

#Commands
ftp.pwd()
ftp.cwd("/")
ftp.retrlines('LIST', listLineCallback)
#ftp.dir()

launch()
'''

这是我从正常工作的测试服务器上得到的...

'''
Press Enter To Initialise Server Connection: 

Server Found
Admin Auto Login...


220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 10:53. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
*cmd* 'PBSZ 0'
*resp* '200 PBSZ=0'
*cmd* 'PROT P'
*resp* '200 Data protection level set to "private"'
*cmd* 'CCC'
*resp* '200 Control connection unencrypted'
Login Successful
*cmd* 'PWD'
*resp* '257 "/" is your current location'
*cmd* 'CWD /'
*resp* '250 OK. Current directory is /'
*cmd* 'TYPE A'
*resp* '200 TYPE is now ASCII'
*cmd* 'PASV'
*resp* '227 Entering Passive Mode (91,103,219,222,232,11)'
*cmd* 'LIST'
*resp* '150 Accepted data connection'
** drwxr-xr-x    2 sensitive   sensitive         4096 Dec 18 15:53 .*
** drwxr-xr-x    2 sensitive   sensitive         4096 Dec 18 15:53 ..*
** -rw-------    1 sensitive   sensitive            4 Oct 28 15:59 .ftpquota*
*resp* '226-Options: -a -l \n226 3 matches total'
'''

这是我尝试连接到主服务器后得到的...

'''
Server Found
Admin Auto Login...


220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 10:57. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
*cmd* 'PBSZ 0'
*resp* '200 PBSZ=0'
*cmd* 'PROT P'
*resp* '200 Data protection level set to "private"'
*cmd* 'CCC'
*resp* '200 Control connection unencrypted'
Login Successful
*cmd* 'PWD'
*resp* '257 "/" is your current location'
*cmd* 'CWD /'
*resp* '250 OK. Current directory is /'
*cmd* 'TYPE A'
*resp* '200 TYPE is now ASCII'
*cmd* 'PASV'
*resp* '227 Entering Passive Mode (91,146,105,202,253,214)'
*cmd* 'LIST'
*resp* '150 Accepted data connection'
Traceback (most recent call last):
  File "C:\Users\install\Desktop\WebsiteConnecting\Website_FTP_Testing.py", line 54, in <module>
    launch()
  File "C:\Users\install\Desktop\WebsiteConnecting\Website_FTP_Testing.py", line 51, in launch
    ftp.retrlines('LIST', listLineCallback)
  File "C:\Users\install\AppData\Local\Programs\Python\Python37\lib\ftplib_custom.py", line 488, in retrlines
    return self.voidresp()
  File "C:\Users\install\AppData\Local\Programs\Python\Python37\lib\ftplib_custom.py", line 251, in voidresp
    resp = self.getresp()
  File "C:\Users\install\AppData\Local\Programs\Python\Python37\lib\ftplib_custom.py", line 236, in getresp
    resp = self.getmultiline()
  File "C:\Users\install\AppData\Local\Programs\Python\Python37\lib\ftplib_custom.py", line 222, in getmultiline
    line = self.getline()
  File "C:\Users\install\AppData\Local\Programs\Python\Python37\lib\ftplib_custom.py", line 210, in getline
    raise EOFError
EOFError
'''

任何帮助将不胜感激,我将根据需要编辑或添加所需内容。

'''
EDIT:
Status:     Resolving address of ########
Status: Connecting to 91.146.105.202:21...
Status: Connection established, initializing TLS...
Error:  GnuTLS error -15: An unexpected TLS packet was received.
Status: Connection attempt failed with "ECONNABORTED - Connection aborted".
Error:  Could not connect to server
Status: Disconnected from server
Status: Selected port usually in use by a different protocol.
Status: Resolving address of ######
Status: Connecting to 91.146.105.202:21...
Status: Connection established, initializing TLS...
Error:  GnuTLS error -15: An unexpected TLS packet was received.
Status: Connection attempt failed with "ECONNABORTED - Connection aborted".
Error:  Could not connect to server
Status: Waiting to retry...
Status: Resolving address of #######
Status: Connecting to 91.146.105.202:21...
Status: Connection established, initializing TLS...
Error:  GnuTLS error -15: An unexpected TLS packet was received.
Status: Connection attempt failed with "ECONNABORTED - Connection aborted".
Error:  Could not connect to server
'''

0 个答案:

没有答案