python - SFTP 通过 Paramiko : Errno 10061 (probably proxy)

标签 python proxy sftp paramiko

我正在尝试使用 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'

任何帮助都是有值(value)的!

最佳答案

Paramiko 本身不实现代理。

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

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

有关示例,请参阅:

关于python - SFTP 通过 Paramiko : Errno 10061 (probably proxy),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32652523/

相关文章:

Python requests.packages.urllib3.connection.VerifiedHTTPSConnection [Errno 11004]

maven - 使用 Maven 通过 SFTP 传输 Artifact

bash - 在 Bash 脚本中指定 sftp 的密码

python - 使用pip安装uwsgi时'ascii'编解码器无法解码错误

python - os.rename 中找不到文件错误

.net - .Net的开源代理库

python - Paramiko 模块的 sftp.get() 设置时间限制

来自 txt 文件的 Python 字数统计程序

python - 使用 scrapy - python 进行 HXS 过滤

git - 使用https时如何通过防火墙访问Github扮演中间人?