What's the standard way to securely transfer files using Python SFTP?

For a simpler interface, consider using pysftp, a higher-level wrapper around Paramiko that simplifies SFTP operations. It provides methods like put() and get() for easier file handling. import pysftp

with pysftp.Connection('THEHOST.com', username='THEUSERNAME', password='THEPASSWORD') as sftp:
    localpath = sys.argv[1]
    remote_path = './THETARGETDIRECTORY/' + sys.argv[1]  # hard-coded
    sftp.put(localpath, remote_path)
    print('Upload done.')