I am new to python paramiko. I am trying to upload files in my client server with sftp using python-paramiko. I have code without proxy setup. Please find that below.
host = "abc.mno.com"
port = 22
proxy_uri = "http://username:password@proxyIP:port"
url = urlparse(proxy_uri)
http_con = http.client.HTTPConnection(url.hostname, url.port)
print(url.hostname)
http_con.trust_env=False
headers = {}
if url.username and url.password:
auth = '%s:%s' % (url.username, url.password)
headers['Proxy-Authorization'] = 'Basic '+auth
print(headers)
http_con.set_tunnel(host, port, headers)
http_con.connect()
sock = http_con.sock client = paramiko.SSHClient()
client.connect(
hostname=host,
port=port,
username='username',
key_filename="E:\\keyfile.pem",
sock=sock,
)
print('connected')
I am trying this in windows server. When I execute the program, I am getting error stating "OSError: Tunnel connection failed: 407 Proxy Authentication Required". How can I authenticate the proxy. Could anyone please help me to connect to sftp with proxy(http) setup.