2011年12月31日星期六

[GFW BLOG(功夫网与翻墙)] SSH via HTTP Proxy

原文:http://terrywang.net/archives/1321

这是一个困扰我许久的问题,因为自己比较懒所以一直没有去就寻根问底,需要用到 SSH Tunnel 时就用 PuTTY 来绕过这个问题。

问 题的产生:公司的网络环境需要走 HTTP Proxy 才能访问外部 Internet。工作机用 Ubuntu ,无论是在 Terminal 中手动设置 http_proxy 还是用 gnome-network-properties GUI 设置全局环境变量,对在命令行中用 ssh 都不起作用。

解决方法: Debian/Ubuntu 下可以安装 connect-proxy 包,以下是包描述:


Description: Establish TCP connection using SOCKS4/5 or HTTP tunnel
connect-proxy is a simple relaying command to make tunnel TCP connection
via SOCKS or HTTPS proxies.
It is mainly intended to be used as proxy command of OpenSSH.

安装后编辑一下 ~/.ssh/config 例如:

## Servers outside the firewall, use HTTP proxy
Host my-ssh-server.com
ProxyCommand connect -H proxy.my-ssh-server.com:80 %h %p
## Sites inside the firewall, do NOT use proxy
Host *
ProxyCommand connect %h %p

保存,再试一下ssh 到我的ssh server搞定!

更多 connect-proxy 的用法请 RTFM 哈。

注意:这样的话也带来了另外一个问题,若切换到家中或其它不需要代理的环境,就会出现连不上我的ssh server 的情况。至于如何解决,大家自行动脑筋吧;-)
还是那句话:世上无难事,只怕有心人。




--
Posted By GFW BLOG 功夫网与翻墙 to GFW BLOG(功夫网与翻墙) at 12/31/2011 09:31:00 AM

--
1、翻墙利器赛风3下载地址: http://dld.bz/caonima326http://dld.bz/caonima745/
2、我们的订阅地址:http://feeds2.feedburner.com/chinagfwblog
3、停止订阅,请发邮件到
gfw-blog+unsubscribe@googlegroups.com
翻越防火长城,你可以到达世界上的每一个角落。(Across the Great Firewall, you can reach every corner in the world.)

没有评论:

发表评论