如何通过 SOCKS 代理运行结构脚本?

发布于 2024-10-30 05:28:43 字数 237 浏览 1 评论 0原文

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

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

I have a SOCKS proxy setup to a gateway server which is created by setting up a host definition in my ssh_config to use DynamicForward localhost:9876. To connect with SSH to the remote server I've setup another host definition to use ProxyCommand /usr/bin/nc -x localhost:9876 %h %p which is all working fine.

However my fabric script needs to connect to that remote server. How can I tell it to use the SOCKS proxy when it connects?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

权谋诡计 2024-11-06 05:28:43

Fabric 现在(2013 年 3 月)原生支持隧道:请参阅导致更改的讨论在代码和 提交消息并给出一些理由。

Tunnelling is now (March 2013) supported by Fabric natively: see the discussion leading to the changes in code and the commit message with a bit of rationale.

ぃ双果 2024-11-06 05:28:43

Fabric 的 SSH 层 目前不支持网关或代理,但它们“最终可能会修补/分叉以添加该功能。” (来自此处)。

Fabric 上还有一个悬而未决的问题,即实现隧道

这篇博文 建议覆盖 run 函数。

Fabric's SSH layer does not support gateways or proxies at the moment but they "may end up patching/forking it sometime to add that functionality." (from here).

There's also an outstanding issue on Fabric to implement tunneling.

This blog post suggests overriding the run function.

微暖i 2024-11-06 05:28:43

您可以使用 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 访问一台主机。

You can use tsocks and the OpenSSH client's built-in support for creating SOCKS tunnels. It requires a bit of configuration but it works fine. Below is how I got started on 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

The fact that Fabric doesn't work without a VPN connection was a deal breaker for me, so this is a great solution; all it requires is SSH access to one host.

染柒℉ 2024-11-06 05:28:43

Fabric (1.12.0)(文档):

 env.use_ssh_config = True

on Fabric (1.12.0)(doc):

 env.use_ssh_config = True
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文