Reputation: 1083
I am trying to connect to SFTP server using Paramiko in Python 2.7.
Here is my code:
# 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')
I get this error:
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
I have searched this issue in different places but still haven't found any decisions.
Port and other credentials to this server are correct. That's for sure, because I can connect to it through SFTP client FileZilla. The code above is working from my personal machine, but it doesn't work from my corporate computer. That's why I think it's because of proxy.
Do you have any suggestions how can I go through proxy in this case?
I already have had environment variables
http_proxy='http://username:password@proxy:port'
https_proxy='https://username:password@proxy:port'
Any help would be valuable!
Upvotes: 2
Views: 2187
Reputation: 202272
The Paramiko itself does not implement proxies.
You have to provide a custom implementation of a "socket" via the sock
parameter of the connect
method.
The httplib.HTTPConnection
can be used as such implementation for HTTP proxies.
For some examples, see:
Upvotes: 1