from ftplib import FTP_TLS import socket import ssl class tyFTP(FTP_TLS): def __init__(self, host='', user='', passwd='', acct='', keyfile=None, certfile=None, timeout=60): FTP_TLS.__init__(self, host, user, passwd, acct, keyfile, certfile, 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.file = self.sock.makefile('rb') self.welcome = self.getresp() except Exception as e: print e return self.welcome server = tyFTP() #Change the host and port server.connect(host="ftps.tracston.com", port=990) #Change the user and password server.login(user="tracston\username", passwd="Password13!") server.prot_p() #Change the directory from the FTP root server.cwd("/home/username") print('Directory changed to ' + server.pwd()) #Change the local file path file = open(r"C:\temp\filetocopy.txt", "rb") #Change the remote file name server.storbinary("STOR filecopied.txt", file) file.close() server.quit()