2011-04-06 116 views
1

我有一個網關服務器的SOCKS代理設置,通過在我的ssh_config中設置主機定義創建,使用DynamicForward localhost:9876。要連接SSH到遠程服務器我已經設置了另一個主機定義,使用ProxyCommand /usr/bin/nc -x localhost:9876 %h %p這一切都正常工作。如何通過SOCKS代理運行結構腳本?

但是,我的光纖腳本需要連接到該遠程服務器。我如何告訴它在連接時使用SOCKS代理?

回答

0

您可以使用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訪問一臺主機。

0

Fabric (1.12.0)doc):

env.use_ssh_config = True