我有一個網關服務器的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