我有一个网关服务器的SOCKS代理设置,通过在我的ssh_config
中设置主机定义创建,使用DynamicForward localhost:9876
。要连接SSH到远程服务器我已经设置了另一个主机定义,使用ProxyCommand /usr/bin/nc -x localhost:9876 %h %p
这一切都正常工作。如何通过SOCKS代理运行结构脚本?
但是,我的光纤脚本需要连接到该远程服务器。我如何告诉它在连接时使用SOCKS代理?
我有一个网关服务器的SOCKS代理设置,通过在我的ssh_config
中设置主机定义创建,使用DynamicForward localhost:9876
。要连接SSH到远程服务器我已经设置了另一个主机定义,使用ProxyCommand /usr/bin/nc -x localhost:9876 %h %p
这一切都正常工作。如何通过SOCKS代理运行结构脚本?
但是,我的光纤脚本需要连接到该远程服务器。我如何告诉它在连接时使用SOCKS代理?
隧道现在(2013年3月)原生支持Fabric:请参阅discussion导致代码更改和commit message有点理由。
Fabric的SSH layer目前不支持网关或代理服务器,但它们“最终可能会修补/ forking以增加该功能。” (从here)。
织物上还存在一个突出问题,即implement tunneling。
This blog post建议覆盖运行功能。
您可以使用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
Fabric没有VPN连接无法正常工作的事实对我来说是一个难题,所以这是一个很好的解决方案;它只需要SSH访问一台主机。
上Fabric (1.12.0)
(doc):
env.use_ssh_config = True