ghickman ghickman - 15 days ago 7
Python Question

How to run a fabric script over a SOCKS proxy?

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?

Answer

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.