為了 git:// 用 tsocks 翻牆
在公司裡因為 firewall 的關係,沒辦法從公司裡面用 git 存取 git:// 的 repository,因此必須想辦法「翻牆」。以下簡述方法:
首先,在外面要有台 SSH server「接應」,利用 SSH tunnel 當作 socks server:
SHELL> ssh -D5487 <account>@<server-address>
然後,安裝 tsocks 這套軟體,在 FreeBSD 裡就是 /usr/ports/net/tsocks,在 Ubuntu 裡就直接找 tsocks 裝即可。裝好後設定檔在 /etc/tsocks.conf 或 /usr/local/etc/tcosks.conf,修改其內容,將 default server 設定改成如下:
# Default server # For connections that aren't to the local subnets or to 150.0.0.0/255.255.0.0 # the server at 192.168.0.1 should be used (again, hostnames could be used # too, see note above) server = 127.0.0.1 # Server type defaults to 4 so we need to specify it as 5 for this one server_type = 5 # The port defaults to 1080 but I've stated it here for clarity. server_port = 5487
然後在執行 git 時,前面冠以 tsocks 指令如下即可:
SHELL> tsocks git clone git://foo.com/bar.git bar
搞定收工。



6 Comments
不能請公司直接開放嗎? 有這等事哦
問過了, 不給開 XD
比我们幸福,我们只有 http_proxy... 还得 map port 透过 http_proxy 获取。。
有沒有想過用 proxychains ?
[聽說比 tsock 好用.
benz,
看起來功能更強大耶,不曉得會不會比較難設定。目前對我來說,tsocks 暫時夠用,有機會再試試 proxychains 囉。Thanks.
-- jeffhung
xwl,
有空的時候,ssh 甚至 http 的 tunnel 都該準備一下,什麼時後會用到都不知道。
-- jeffhung
Post a Comment