ubuntu下安装配置shadowsock

转载地址:http://blog.csdn.net/lee_j_r/article/details/54019691

1、安装 shadowsocks 客户端

ss 的客户端有很多语言实现,包括 Python、Go、libev等,这里使用广泛的 Python 后端。

[plain]  view plain  copy
  1. sudo apt-get update  
  2. sudo apt-get install python-pip    
  3. sudo pip install shadowsocks    
(如果有安装过pip的可以不用重新安装pip了)

此时系统会多出来两个程序:

[python]  view plain  copy
  1. /usr/bin/ssserver  
  2. /usr/bin/sslocal  
[python]  view plain  copy
  1. ubuntu@ubuntu-System:~$ ssserver -h  
  2. usage: ssserver [OPTION]...  
  3. A fast tunnel proxy that helps you bypass firewalls.  
  4.   
  5. You can supply configurations via either config file or command line arguments.  
  6.   
  7. Proxy options:  
  8.   -c CONFIG              path to config file  
  9.   -s SERVER_ADDR         server address, default: 0.0.0.0  
  10.   -p SERVER_PORT         server port, default: 8388  
  11.   -k PASSWORD            password  
  12.   -m METHOD              encryption method, default: aes-256-cfb  
  13.   -t TIMEOUT             timeout in seconds, default: 300  
  14.   --fast-open            use TCP_FASTOPEN, requires Linux 3.7+  
  15.   --workers WORKERS      number of workers, available on Unix/Linux  
  16.   --forbidden-ip IPLIST  comma seperated IP list forbidden to connect  
  17.   --manager-address ADDR optional server manager UDP address, see wiki  
  18.   
  19. General options:  
  20.   -h, --help             show this help message and exit  
  21.   -d start/stop/restart  daemon mode  
  22.   --pid-file PID_FILE    pid file for daemon mode  
  23.   --log-file LOG_FILE    log file for daemon mode  
  24.   --user USER            username to run as  
  25.   -v, -vv                verbose mode  
  26.   -q, -qq                quiet mode, only show warnings/errors  
  27.   --version              show version information  
  28.   
  29. Online help: <https://github.com/shadowsocks/shadowsocks>  

2、配置shadowsocks

[python]  view plain  copy
  1. sudo gedit /etc/shadowsocks.json  
然后会跳出一个文本框,粘贴以下内容

[python]  view plain  copy
  1. {  
  2.     "server":"xx.xx.xx.xx",  
  3.     "server_port":xxxx,  
  4.     "local_address""127.0.0.1",  
  5.     "local_port":1080,  
  6.     "password":"xxxxxxxx",  
  7.     "timeout":300,  
  8.     "method":"aes-256-cfb",  
  9.     "fast_open": true,  
  10.     "workers"1  
  11. }  
修改成你自己的服务器信息。保存退出。

3、启动shadowsocks

[python]  view plain  copy
  1. sudo sslocal -c /etc/shadowsocks.json -d start     
这样,shadowsocks就运行了。但怎么通过它上网呢,这就要设置浏览器了。下面介绍火狐和chrome浏览器的设置。

4、火狐浏览器,代理设置

    4.1、在 “附加组件->扩展” 中搜索foxystandard
    4.2、安装后点开首选项配置
    4.3、工作模式切换为 “使用其基于其预定义模板的代理服务器”
    4.4、“代理服务器->新建代理服务器->常规->代理名称” 代理名称随便写xxx,
         “->代理服务器细节”  选择“手动配置代理服务器”,“IP” 127.0.0.1 ,“端口”:1080
        选择“socks v5”
    4.5、 工作模式切换为 “为全部URLS启用代理服务器xxx”,选择“模式订阅”,点“转到”,“订阅名称”随便写xxx,“订阅网址” http://www.woodbunny.com/gfwlist.txt,“添加代理服务器” xxx,“Format” AutoProxy,"Obfuscation" base64,点击“确定”,应该提示添加成功,否则可能没有打开sslocal。
    4.6、关闭窗口,应该百度谷歌都可以上了。

5、chrome浏览器,代理设置

    5.1、点击浏览器右上角三个点,“更多工具”,"扩展程序",“获取更多扩展程序”,搜索“proxy switchysharp”,下载安装

    5.2、然后打开 Proxy SwitchySharp 的设置,新建一个情景,命名为 Shadowsocks,并设置好端口,模式为 socks5 如图:


再点切换规则,由于可能大概无法访问 Google,我们就启用切换规则,然后在 URL 模式里输入 *google* 统配好 Google 的所有域名,选择好模式匹配为通配符,情景模式为 Shadowsocks
然后把在线规则列表打钩,输入 URL 为:

[python]  view plain  copy
  1. https://autoproxy-gfwlist.googlecode.com/svn/trunk/gfwlist.txt  
勾选  AutoProxy 兼容列表 ,然后点立即更新,更新完成后保存即可,如图:

6、配置开机启动

[python]  view plain  copy
  1. sudo gedit /etc/rc.local    
在exit0上一行加上/usr/local/bin/sslocal -c /etc/shadowsocks.json -d start

7、设置终端使用代理

[python]  view plain  copy
  1. git clone https://github.com/rofl0r/proxychains-ng.git  
  2. cd proxychains-ng  
  3. ./configure  
  4. make   
  5. sudo make install  
  6. sudo cp ./src/proxychains.conf /etc/proxychians.conf  
  7. cd .. && rm -rf proxychains-ng  
  8. sudo gedit /etc/proxychains.conf  
最后一行改为socks5  127.0.0.1 1080  //1080端口

保存退出即可。

以后在终端要使用代理的命令就在命令的前面加上sudo proxychains4
可以终端输入以下命令测试:

[python]  view plain  copy
  1. sudo proxychains4 wget http://www.google.com  
如果能成功下载一个index.html文件说明已经代理成功。

8、参考文章

1)ubuntu下配置shadowsock

2)科学上网利器 Shadowsocks 使用方法

3)使用shadowsocks轻松搭建翻墙环境教程

猜你喜欢

转载自blog.csdn.net/qfire/article/details/80541946