特殊国情下,翻墙呼吸点新鲜空气是必须的,windows下通过Tunnerlier等设置,即可为浏览器和程序提供socks5代理。但linux下呢?典型的VMware下的linux环境下,,通过ssh设置即可。
# ssh -qTfnN -D 7070 用户名@远程ssh主机名
上面的7070是本地未被占用的端口,可以自己选择。其它参数的意思是:
-q :- be very quite, we are acting only as a tunnel.
-T :- Do not allocate a pseudo tty, we are only acting a tunnel.
-f :- move the ssh process to background, as we don’t want to interact with this ssh session directly.
-N :- Do not execute remote command.
-n :- redirect standard input to /dev/null.
或者安装 putty,终端输入命令
#plink -C -D 127.0.0.1:7070 -N -pw 密码 用户名@远程ssh主机名
然后输入密码。
然后在本地浏览器上设置代理,选择socket5(firefox等有选项),主机为localhost,端口为上面设置的7070。这样就可以通过代理上网了。
自动选择代理:
在linux下,firefox安装autoproxy,chrome安装proxy switchy,添加规则对被屏蔽的网站使用上面创建的代理,其余按照正常方式直接访问。
自动ssh连接:
有些ssh连接可能有无操作的时效限制,为了实现断线后的自动连接,可以先实现免密码ssh登录,然后安装autossh用下面的命令连接:
#autossh -M 2000 -N -D 127.0.0.1:7070 用户名@远程主机名
如果是命令行如何使用ssh呢?
安装tsocks:
#wget http://pkgs.repoforge.org/tsocks/tsocks-1.8-7.beta5.2.el6.rf.i686.rpm
#rpm -ivh tsocks-1.8-7.beta5.2.el6.rf.i686.rpm
#vim /etc/tsocks.conf
local = 192.168.0.0/255.255.255.0
#local表示本地的网络,也就是不使用socks代理的网络
server = 192.168.0.1
#SOCKS 服务器的 IP
server_type = 5
#SOCKS 服务版本
server_port = 7070
#SOCKS 服务使用的端口
tsocks使用方法:
#tsocks yum update
相关文章