使用python-paramiko使用sftp和proxyhttp上传文件

问题描述

我是python paramiko的新手。我正在尝试使用python-paramiko使用sftp在客户端服务器中上传文件我有没有代理设置的代码。请在下面找到。

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')

我正在Windows服务器中尝试此操作。当我执行程序时,出现错误提示“ OSError:隧道连接失败:407需要代理身份验证”。如何验证代理。 谁能帮助我通过代理(http)设置连接到sftp。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)