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

2024-09-26 22:54:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个网关服务器的SOCKS代理设置,它是通过在我的ssh_config中设置一个主机定义来使用DynamicForward localhost:9876来创建的。为了使用SSH连接到远程服务器,我设置了另一个主机定义来使用ProxyCommand /usr/bin/nc -x localhost:9876 %h %p,这一切都很好。在

但是我的结构脚本需要连接到那个远程服务器。我如何告诉它在连接时使用SOCKS代理?在


Tags: 服务器configlocalhost代理网关bin远程定义
3条回答

Fabric的SSH layer目前不支持网关或代理,但它们“可能会在某个时候修补forking来添加该功能。”(来自here)。在

还有一个关于织物到implement tunneling的悬而未决的问题。在

This blog post建议重写run函数。在

隧道挖掘现在(2013年3月)由Fabric本机支持:请参阅导致代码更改的discussion和带一些基本原理的commit message。在

您可以使用tsocks和OpenSSH客户机的内置支持来创建SOCKS隧道。它需要一些配置,但它工作得很好。下面是我如何开始使用ubuntu10.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

事实上,Fabric在没有VPN连接的情况下无法工作,这对我来说是一个很好的解决方案;它只需要对一个主机进行SSH访问。在

相关问题 更多 >

    热门问题