Skip to content

Instantly share code, notes, and snippets.

@yuest
Created August 12, 2012 04:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuest/3329760 to your computer and use it in GitHub Desktop.
Save yuest/3329760 to your computer and use it in GitHub Desktop.
在 Windows 7 上 建立 ssh -D 快捷方式 - blogist.yue.st

为了让女朋友方便上网,在她的 Windows 7 系统上建立了一个双击便可通过 ssh -D 建立 socks5 代理服务器的快捷方式,记录一下经验。

先安装 cygwin。然后,说明下,我通常是用 ssh -NvgD 7070 example@example.com 命令建立 socks5 代理,-N -v -g 的意义可查 ssh 手册。

另外,我还会用一个 while true; do 语句来保证 ssh 的断线重连:

while true; do ssh -NvgD 7070 e@e.com; sleep 1; done

sleep 1 表示断线后过一秒再重试。

做双击自动连接的快捷方式废了不少时间,没能搞定,于是把上面的命令做成 bash script 放到 C:\cygwin\home\Celine\fuckgfw.sh,然后创建的快捷方式 Target 为:

C:\cygwin\bin\mintty.exe -i C:\cygwin\home\Celine\fuckgfw.ico C:\cygwin\bin\bash.exe -l fuckgfw.sh

为了好看,我还制作了一个 GFW 打砖块的 ico,作为附件放到这个 gist 里面啦。可以右键点击快捷方式属性,在快捷方式属性里面改图标。

注:此为尝试用 gist 写 blog 的第一篇。用 gist 分享技术笔记不错,因为可加附件。

PS. 总是开着一个命令行窗口显示 ssh 信息也是一件很烦的事情。推荐一个小软件 RBTray,下载解压缩后加入到 startup,以后都可以在窗口右上角最小化按钮上点击右键,就可以最小化到系统托盘了。

while true; do
ssh -NvgD 7070 e@e.com;
sleep 1;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment