On this page
ftplib.FTP_TLS
Prev: ftplib.FTP | Up: ftplib
Rel: ftplib.error_perm, ftplib.error_proto, ftplib.error_reply, ftplib.error_temp
Ref: docs.python.org — ftplib.FTP_TLS
Tags: #public #python3 #stdlib #ftplib
Import
import ftplib
from ftplib import FTP_TLS
Signature & Overview
ftplib.FTP_TLS(host='', user='', passwd='', acct='', *, context=None, timeout=<object object at 0x1040b4980>, source_address=None, encoding='utf-8')
A FTP subclass which adds TLS support to FTP as described in RFC-4217.
Methods & Attributes
FTP_TLS.abort(self)—FTP_TLS.abortmethod/property.FTP_TLS.acct(self, password)— Send new account name.FTP_TLS.auth(self)— Set up secure control connection by using TLS/SSL.FTP_TLS.ccc(self)— Switch back to a clear-text control connection.FTP_TLS.close(self)— Close the connection without assuming anything about it.FTP_TLS.connect(self, host='', port=0, timeout=-999, source_address=None)— Connect to host. Arguments are: - host: hostname to connect to (string, default previous host) - port: port to connect to (integer, default previous port)FTP_TLS.cwd(self, dirname)— Change to a directory.FTP_TLS.debug(self, level)— Set the debugging level.FTP_TLS.delete(self, filename)— Delete a file.FTP_TLS.dir(self, *args)— List a directory in long form.FTP_TLS.getline(self)—FTP_TLS.getlinemethod/property.FTP_TLS.getmultiline(self)—FTP_TLS.getmultilinemethod/property.FTP_TLS.getresp(self)—FTP_TLS.getrespmethod/property.FTP_TLS.getwelcome(self)— Get the welcome message from the server.FTP_TLS.login(self, user='', passwd='', acct='', secure=True)—FTP_TLS.loginmethod/property.FTP_TLS.makepasv(self)— Internal: Does the PASV or EPSV handshake -> (address, port)FTP_TLS.makeport(self)— Create a new socket and send a PORT command for it.FTP_TLS.mkd(self, dirname)— Make a directory, return its full pathname.FTP_TLS.mlsd(self, path='', facts=[])— List a directory in a standardized format by using MLSD command (RFC-3659). If path is omitted the current directory is assumed. "facts" is a list of strings representing the typeFTP_TLS.nlst(self, *args)— Return a list of files in a given directory (default the current).FTP_TLS.ntransfercmd(self, cmd, rest=None)—FTP_TLS.ntransfercmdmethod/property.FTP_TLS.prot_c(self)— Set up clear text data connection.FTP_TLS.prot_p(self)— Set up secure data connection.FTP_TLS.putcmd(self, line)—FTP_TLS.putcmdmethod/property.FTP_TLS.putline(self, line)—FTP_TLS.putlinemethod/property.FTP_TLS.pwd(self)— Return current working directory.FTP_TLS.quit(self)— Quit, and close the connection.FTP_TLS.rename(self, fromname, toname)— Rename a file.FTP_TLS.retrbinary(self, cmd, callback, blocksize=8192, rest=None)— Retrieve data in binary mode. A new port is created for you.FTP_TLS.retrlines(self, cmd, callback=None)— Retrieve data in line mode. A new port is created for you.FTP_TLS.rmd(self, dirname)— Remove a directory.FTP_TLS.sanitize(self, s)—FTP_TLS.sanitizemethod/property.FTP_TLS.sendcmd(self, cmd)— Send a command and return the response.FTP_TLS.sendeprt(self, host, port)— Send an EPRT command with the current host and the given port number.FTP_TLS.sendport(self, host, port)— Send a PORT command with the current host and the given port number.FTP_TLS.set_debuglevel(self, level)— Set the debugging level.FTP_TLS.set_pasv(self, val)— Use passive or active mode for data transfers.FTP_TLS.size(self, filename)— Retrieve the size of a file.FTP_TLS.storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None)— Store a file in binary mode. A new port is created for you.FTP_TLS.storlines(self, cmd, fp, callback=None)— Store a file in line mode. A new port is created for you.
Usage
import ftplib
# Explicit FTPS client; remember to call ftp.prot_p() after login() to encrypt data transfers
ftps = ftplib.FTP_TLS()
assert isinstance(ftps, ftplib.FTP)
Gotchas
- FTPS ≠ SFTP: Cannot connect to SSH/SFTP (port 22). Always call
ftps.prot_p()afterlogin()so the data channel is encrypted too.
REPL Inspect
from ftplib import FTP_TLS
help(FTP_TLS)
Linked from
Related notes
- tuts/python3/stdlib_module/ftplib/FTP Linked here; links to this page; shared tags: #ftplib, #stdlib
- tuts/python3/stdlib_module/ftplib Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/ftplib/error_perm Linked here; shared tags: #ftplib, #stdlib
- tuts/python3/stdlib_module/ftplib/error_proto Linked here; shared tags: #ftplib, #stdlib
- tuts/python3/stdlib_module/ftplib/error_reply Linked here; shared tags: #ftplib, #stdlib
- tuts/python3/stdlib_module/ftplib/error_temp Linked here; shared tags: #ftplib, #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib