配置ShadowSocks服务器

由于渣百度找不出什么有用的东西,经常性需要上外网。还好有科学上网利器Shadowsocks。

UBUNTU上配置ShadowSocks还算比较简单

安装Python依赖包

1
2
$ sudo apt-get update
$ sudo apt-get install python-gevent python-pip

安装ShadowSocks

1
$ sudo pip install shadowsocks

创建配置文件

我把配置文件放在/var/shadowsocks.json

1
$ sudo nano /var/shadowsocks.json

单用户配置

1
2
3
4
5
6
7
8
9
10
{
"server":"your_server_ip",
"server_port":8989,
"local_address":"127.0.0.1",
"local_port":1080,
"password":"yourpassword",
"timeout":300,
"method":"aes-256-cfb",
"fast_open": false
}

多用户配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"server":"your_server_ip",
"local_address": "127.0.0.1",
"local_port":1080,
"port_password":{
"8989":"password0",
"9001":"password1",
"9002":"password2",
"9003":"password3",
"9004":"password4"
},
"timeout":300,
"method":"aes-256-cfb",
"fast_open": false
}

有些服务器商不能用你的 ip 作为 server。这种情况可以尝试把 server 设置为 0.0.0.0

最后在运行

1
$ sudo apt-get install python-m2crypto

先运行一下测试

1
$ ssserver -c /var/shadowsocks.json

然后客户端连上去后打开网页,如果能看到一下提示,就说明正常。

1
2
3
4
5
6
# ssserver -c /var/shadowsocks.json
INFO: loading config from /var/shadowsocks.json
2015-02-25 13:38:03 INFO loading libcrypto from libcrypto.so.1.0.0
2015-02-25 13:38:03 INFO starting server at 104.236.164.230:8989
2015-02-25 13:38:08 INFO connecting www.google.com.sg:443 from 117.145.201.127:22817
2015-02-25 13:38:09 INFO connecting google.com:80 from 117.145.201.127:22818

但这样关掉SSH就会断开,所以用下面命令添加到/etc/rc.local开机启动

1
/usr/local/bin/ssserver -c /var/shadowsocks.json