What’s the best way to automate secure FTP in PowerShell?

After some experimentation I came up with this way to automate a secure FTP download in PowerShell. This script runs off the public test FTP server administered by Chilkat Software. So you can copy and paste this code and it will run without modification. $sourceuri = “ftp://ftp.secureftp-test.com/hamlet.zip” $targetpath = “C:\hamlet.zip” $username = “test” $password = … Read more

FTPS with Python ftplib – Session reuse required

It can be now easily fixed for Python 3.6+ by this class (descendant of FTP_TLS): class MyFTP_TLS(ftplib.FTP_TLS): “””Explicit FTPS, with shared TLS session””” def ntransfercmd(self, cmd, rest=None): conn, size = ftplib.FTP.ntransfercmd(self, cmd, rest) if self._prot_p: conn = self.context.wrap_socket(conn, server_hostname=self.host, session=self.sock.session) # this is the fix return conn, size It takes the TLS session information from … Read more

How to connect to FTPS server with data connection using same TLS session?

Indeed some FTP(S) servers do require that the TLS/SSL session is reused for the data connection. This is a security measure by which the server can verify that the data connection is used by the same client as the control connection. Some references for common FTP servers: vsftpd: https://scarybeastsecurity.blogspot.com/2009/02/vsftpd-210-released.html FileZilla server: https://svn.filezilla-project.org/filezilla?view=revision&revision=6661 ProFTPD: http://www.proftpd.org/docs/contrib/mod_tls.html#TLSOptions (NoSessionReuseRequired … Read more