Currently, I am doing SFTP transfer using Python subprocess.POPEN
and PuTTY psftp.exe
.
It is working, but not really clean nor transportabl
I do not think that the pysftp supports proxies. Though note that the pysftp is just a wrapper around Paramiko library, which does support proxies.
So I suggest you to use Paramiko directly.
For a start see How to ssh over HTTP proxy in Python Paramiko?, particularly the answer by @tintin.
To authenticate to the proxy, after the CONNECT
command, add a Proxy-Authorization
header like:
Proxy-Authorization: Basic
where the
is base-64 encoded string username:password
.
auth = 'Basic ' + base64.encodebytes("username:password".encode()).decode()
args = ("123.123.123.255", 23, auth)
cmd_connect = "CONNECT {}:{} HTTP/1.1\r\nProxy-Authorization: {}\r\n\r\n".format(*args)