So, I need to connect to SSH server through proxy socks. I read paramiko and twisted.conch docs, but didn`t found proxy socks support there.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
This socket-wrapper allows you to use static ssh-tunnels. I found a common solution for my problem:
- Use paramiko
SSHClient
class - Extend
SSHClient
with your own class - Re-implement the
connect()
method: Instead of using a standard socket object we pass to it a fixed proxied socket from the python packagesockipy
回答2:
Paraproxy (a Paramiko addon for SSH2 ProxyCommands) looks like it can do it. There's no documentation online but in downloading the source and inspecting the README
file, I found this:
Paraproxy is a supplement to the great "paramiko" SSH2 module. While paramiko has a really good support for SSH(2) it lacks the ProxyCommand feature.
ProxyCommands can be used e.g. to connect to VPN tunnels but they provide manny other nice features.
Paraproxy, once imported will hook into the SSHClient class provided by paramiko which in turn gains full support for SSH ProxyCommands.
No changes to existing code are needed.
Give that a shot!