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

问题描述 投票:2回答:1

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

任何帮助都是有价值的!

python proxy sftp paramiko
1个回答
1
投票

Paramiko本身不实现代理。

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

httplib.HTTPConnection可以用作HTTP代理的这种实现。

详情见: https://www.adimian.com/blog/2014/10/paramiko-and-corporate-proxies/

© www.soinside.com 2019 - 2024. All rights reserved.