Python ssh client over socks (proxy)

2019-04-11 22:10发布

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.

2条回答
再贱就再见
2楼-- · 2019-04-11 22:48

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!

查看更多
干净又极端
3楼-- · 2019-04-11 23:06

This socket-wrapper allows you to use static ssh-tunnels. I found a common solution for my problem:

  1. Use paramiko SSHClient class
  2. Extend SSHClient with your own class
  3. Re-implement the connect() method: Instead of using a standard socket object we pass to it a fixed proxied socket from the python package sockipy
查看更多
登录 后发表回答