Skip to content

Instantly share code, notes, and snippets.

@Ryanb58
Last active February 16, 2023 11:03
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Ryanb58/43e8bf5a8935405c455c5b41f8f8a0a3 to your computer and use it in GitHub Desktop.
Save Ryanb58/43e8bf5a8935405c455c5b41f8f8a0a3 to your computer and use it in GitHub Desktop.
Quick script to connect to a FTPS server via python.
# WOrks in python 2.7 not sure if it works in python 3.
# Just straight up connect by any means possible.
from ftplib import FTP_TLS
def connect():
ftp = FTP_TLS()
ftp.debugging = 2
ftp.connect('localhost', 2121)
ftp.login('developer', 'password')
return ftp
ftp = connect()
ftp.retrlines('LIST')
# Connect, but only using SSL version 2 aor 3
from ftplib import FTP_TLS
import ssl
def connect():
ftp = FTP_TLS()
ftp.ssl_version = ssl.PROTOCOL_SSLv23
ftp.debugging = 2
ftp.connect('localhost', 2121)
ftp.login('developer', 'password')
return ftp
# Connect, but only using TLS version 1.2
from ftplib import FTP_TLS
import ssl
def connect():
ftp = FTP_TLS()
ftp.ssl_version = ssl.PROTOCOL_TLSv1_2
ftp.debugging = 2
ftp.connect('localhost', 2121)
ftp.login('developer', 'password')
return ftp
ftp = connect()
ftp.retrlines('LIST')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment