如何在SOCKS代理上运行结构脚本?

我有一个SOCKS代理设置到网关服务器,通过在我的
ssh_config
中设置主机定义来创建使用
DynamicForward localhost:9876
。要使用SSH连接到远程服务器,我已经设置了另一个主机定义来使用
ProxyCommand /usr/bin/nc -x localhost:9876 %h %p
,这一切都正常。 但是我的结构脚本需要连接到该远程服务器。如何在连接时告诉它使用SOCKS代理?     
已邀请:
隧道现在(2013年3月)由Fabric本地支持:请参阅讨论导致代码和提交消息的更改,并提供一些基本原理。     
Fabric的SSH层目前不支持网关或代理,但它们“可能会在某个时候修补/分配它以添加该功能。” (从这里)。 Fabric上还有一个突出的问题就是实现隧道效应。 这篇博文建议覆盖run函数。     
您可以使用tsocks和OpenSSH客户端的内置支持来创建SOCKS隧道。它需要一些配置,但它工作正常。以下是我如何开始使用Ubuntu 10.04。
# Install the tsocks library and shell script.
sudo apt-get install tsocks

# Configure the range of IP addresses you need access to.
sudo nano /etc/tsocks.conf

# Use the OpenSSH client to create a socks proxy (stepping
# stones are hosts used to gain access to private subnets).
ssh -D 1080 stepping.stone

# Now connect to any given address in your configured range.
# tsocks will intercept the connection and route it using
# the SOCKS proxy we created with the previous command.
tsocks ssh 1.2.3.4
如果没有VPN连接,Fabric无法正常工作这对我来说是一个交易破坏者,所以这是一个很好的解决方案;它需要的是对一个主机的SSH访问。     
Fabric (1.12.0)
(doc):
 env.use_ssh_config = True
    

要回复问题请先登录注册