2011-04-06 63 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