Mac 通过代理服务器 ssh

在学校、公司大多时候都需要通过代理服务器上网,想在 Mac 下通过代理服务器 ssh 的话可以使用 Corkscrew 小工具。Corkscrew 也支持 Linux。

下载 corkscrew-2.0.tar.gz 后解压编译,然后拷贝编译生成的 corkscrew 到用户的主目录下的 .ssh 中:

$ tar zxvf corkscrew-2.0.tar.gz
$ cd corkscrew-2.0
$ ./configure --host=apple
$ make
$ cp corkscrew $HOME/.ssh/

打开 .ssh/config,增加以下几行:

$ vi .ssh/config

Host vpsee.com 67.203.229.22
ProxyCommand /Users/vpsee/.ssh/corkscrew proxy.server.address 3128 %h %p
TCPKeepAlive yes
ServerAliveInterval 5

注意:把上面的 vpsee.com 67.203.229.22 换成要 ssh 的服务器地址(可以有多个,可以是域名也可以是 IP 地址);把 proxy.server.address 3128 换成相应的代理服务器地址和端口号;TCPKeepAlive 用来与 ssh 服务器保持连接。

ssh 服务器为了安全考虑发现客户端长时间闲置的话会主动断开 ssh 连接,如果不想 ssh 自动断开,ssh 客户端需要打开 TCPKeepAlive 选项定时给服务器发 TCP 包来欺骗服务器,让 ssh 服务器感觉客户端还在 “活动” 中。同时 ssh 服务器端也需要打开 TCPKeepAlive 选项(也就是说,ssh 客户端配置和 ssh 服务器端配置都要打开 TCPKeepAlive):

# vi /etc/ssh/sshd_config

TCPKeepAlive yes

评论 (2 Comments)

  1. 不会啊!!!!

  2. 你好,请问这个搞好还是在终端里面ssh吗?照做了,终端ssh登不了

发表评论