活到老学到老  

记录遇到问题的点点滴滴。

linux 通过ssh代理上网

6年前发布  · 1379 次阅读
  ssh  隧道 

linux 通过ssh代理上网
本网段上网需计费,想到通过另一网段的linux服务器做代理免费上网
前提是你有那台linux主机的帐户
然后打开终端输入

ssh -qTfnN -D 7070 user@host



说明: user是你的帐号,host指对方linux主机的ip
-q Quiet mode. 安静模式,忽略一切对话和错误提示。
-T Disable pseudo-tty allocation. 不占用 shell 了。
-f Requests ssh to go to background just before command execution. 后台运行,并推荐加上 -n 参数。
-n Redirects stdin from /dev/null (actually, prevents reading from stdin). -f 推荐的,不加这条参数应该也行。
-N Do not execute a remote command. 不执行远程命令,专为端口转发度身打造。


然后在浏览器中
如果是firefox:安装autoproxy插件,在代理中选择SSH -D即可。默认情况下的配置就是7070端口,所以可以不用修改配置,否则在首选项中更改服务器设置。
如果是Chrome:安装proxy switchy扩展,添加Proxy Profile,在右侧的socks host中输入127.0.0.1和7070,下方选中socks v5,保存,然后切换至该profile即可。