通过 Paramiko 的 SFTP:Errno 10061(可能是代理)

SFTP through Paramiko: Errno 10061 (probably proxy)

我正在尝试使用 Python 2.7 中的 Paramiko 连接到 SFTP 服务器。

这是我的代码:

# Python 2.7
# -*- coding: utf-8 -*-
import paramiko

# Connect to Server
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('ip_address',port = 22,username='user',password='password')

我收到这个错误:

Traceback (most recent call last):
File "C:\Python27\lib\socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 10061] No connection could be made because the target machine actively refused it

我在不同的地方搜索过这个问题,但仍然没有找到任何决定。

此服务器的端口和其他凭据正确。这是肯定的,因为我可以通过 SFTP 客户端 FileZilla 连接到它。 上面的代码在我的个人计算机上运行,​​但在我的公司计算机上不起作用。这就是为什么我认为这是因为代理。

你对我在这种情况下如何通过代理有什么建议吗?

我已经有了环境变量

http_proxy='http://username:password@proxy:port'
https_proxy='https://username:password@proxy:port'

任何帮助都是有价值的!

Paramiko 本身不实现代理。

您必须通过 connect methodsock 参数提供“套接字”的自定义实现。

httplib.HTTPConnection 可用作 HTTP 代理的此类实现。

有关示例,请参阅: