4

次の方法で SSH サーバーに接続しようとしています。

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')

そして、次のエラーを取得します

> 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

私の目標は、次のようにSSH SOCKSプロキシを作成するパテの方法をシミュレートすることです: Configure PuTTY To Create SSH SOCKS Proxy For Secure Browsing。または同等

ssh -D [ローカルホスト] ポート

ローカルの動的なアプリケーション レベルのポート フォワーディング用。

何が問題なのか、paramiko を使用して正しい方法で行う方法を誰かが説明できますか? ありがとう。

PS私はこれを見つけましたhttps://stackoverflow.com/a/5823383/1264304しかし、私はそれを実装することに成功しません。誰か?

4

1 に答える 1