I'm trying to connect to SSH server in the following way:
import paramiko
import socks
sock = socks.socksocket()
sock.setproxy(socks.PROXY_TYPE_SOCKS5, 'localhost', 22, True)
sock.connect((**IP address of SSH server**, 22))
t = paramiko.Transport(sock)
t.connect( None, 'username', 'password')
And get the following error
> Traceback (most recent call last): ...
> sock.connect((**IP address of SSH server**, 22)) File "C:\Python27\lib\site-packages\socks.py", line 368, in connect
> _orgsocket.connect(self,(self.__proxy[1],portnum)) File "C:\Python27\lib\socket.py", line 224, in meth
> return getattr(self._sock,name)(*args) socket.error: [Errno 10061] No connection could be made because the target machi ne actively
> refused it
My goal is to simulate Putty's way in creating SSH SOCKS Proxy as here: Configure PuTTY To Create SSH SOCKS Proxy For Secure Browsing. Or equivalent
ssh -D [localhost]port
for local dynamic application-level port forwarding.
Can someone explain, please, what's wrong and how to do it the right way using paramiko? Thanks.
P.S. I've found this https://stackoverflow.com/a/5823383/1264304 However, I don't succeed to implement it. Someone?