开发者

Python ssh client over socks (proxy)

开发者 https://www.devze.com 2023-03-01 01:39 出处:网络
So, I need to connect to SSH server through proxy socks. I rea开发者_如何学编程d paramiko and twisted.conch docs, but didn`t found proxy socks support there.This socket-wrapper allows you to use stati

So, I need to connect to SSH server through proxy socks. I rea开发者_如何学编程d paramiko and twisted.conch docs, but didn`t found proxy socks support there.


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


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!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号