python - Trying to connect to FTP site but getting wrong SSL version number error? -
i using python 2.7. established connection ftp site using port 990. however, there un update site need switch port 22. changed port number 990 22. however, after did got error:
[ssl: wrong_version_number] wrong version number (_ssl.c:661)
i have tried checking other similar posts suggest appending https:// site. i'm using ftp , not url not possibility me. have tried changing ssl_version ssl.protocol_sslv23 following error:
[ssl: unknown_protocol] unknown protocol (_ssl.c:661)
here full code provided. know issue is? help.
from ftplib import ftp_tls import socket import ssl class tyftp(ftp_tls): def __init__(self, host='', user='', passwd='', acct='', keyfile=none, certfile=none, context=none, timeout=60): ftp_tls.__init__(self, host, user, passwd, acct, keyfile, certfile, context, timeout) def connect(self, host='', port=0, timeout=-999): if host != '': self.host = host if port > 0: self.port = port if timeout != -999: self.timeout = timeout try: self.sock = socket.create_connection((self.host, self.port), self.timeout) self.af = self.sock.family self.sock = ssl.wrap_socket(self.sock, self.keyfile, self.certfile, ssl_version=ssl.protocol_tlsv1) # self.sock = ssl.wrap_socket(self.sock, self.keyfile, self.certfile, ssl_version=ssl.protocol_sslv23) self.file = self.sock.makefile('rb') self.welcome = self.getresp() except exception e: print e return self.welcome ftp_site = "sftp.mysite.com" upload = { "username": "username", "password": "password" } download = { "username": "username", "password": "password" } server = tyftp() # changed 990. 990 works no issues. server.connect(host=ftp_site, port=22)
990 port implicit ftps while 22 port ssh , sftp. guess did not switch port switched ftps (ftp on ssl) sftp (file transfer on ssh). suggests hostname use: sftp.mysite.com
.
ftps , sftp different protocols , can not use code implementing ftps connect sftp server. libraries supporting sftp in python see google search.
Comments
Post a Comment