Server部署
使用Shadowsocks需要在VPS上部署Server,目前有用Python、Go和C编写的Server端程序。我在VPS上部署的是使用Python版本,所以后面介绍的都是基于Python版本
First, make sure you have Python 2.6 or 2.7.
$ python --version Python 2.6.8
Then install from PIP
$ pip install shadowsocks
如果要了解其他版本的部署方式查看:https://shadowsocks.org/en/download/servers.html
Server配置
SS安装以后需要进行配置,SS使用JSON格式文件进行配置,配置文件路径和名字可以自己决定,一般放在:
/etc/shadowsocks.json
格式如下:
{ "server":"my_server_ip", "server_port":8388, "local_address": "127.0.0.1", "local_port":1080, "password":"mypassword", "timeout":300, "method":"aes-256-cfb", "fast_open": false
}
解释如下:
Name | Explanation |
---|---|
server | 你VPS的IP地址,IPV4,IPV6都可以 |
server_port | 提供SS服务的端口号,写自己想用的端口号 |
local_address | the address your local listens |
local_port | local port |
password | 传输数据时用来加密的密钥,和Client相同 |
timeout | 连接超时时间 |
method | 加密方法 推荐使用 “aes-256-cfb” |
fast_open | use TCP_FASTOPEN, true / false |
workers | number of workers, available on Unix/Linux |
多用户配置
使用port_password,每个用户对应一个端口,然后后面是密码。如果想搭建一个用户管理系统,参见:Manager API.
{
"server": "0.0.0.0",
"port_password": {
"8381": "foobar1",
"8382": "foobar2",
"8383": "foobar3",
"8384": "foobar4"
},
"timeout": 300,
"method": "aes-256-cfb"
}
加密方式
以下是支持的加密方法,table和RC4已经不推荐使用
https://shadowsocks.org/en/spec/cipher.html
Method Name | Key Size | IV Length |
---|---|---|
0 | 0 | |
aes-128-ctr | 16 | 16 |
aes-192-ctr | 24 | 16 |
aes-256-ctr | 32 | 16 |
aes-128-cfb | 16 | 16 |
aes-192-cfb | 24 | 16 |
aes-256-cfb | 32 | 16 |
bf-cfb | 16 | 8 |
camellia-128-cfb | 16 | 16 |
camellia-192-cfb | 24 | 16 |
camellia-256-cfb | 32 | 16 |
cast5-cfb | 16 | 8 |
chacha20 | 32 | 8 |
chacha20-ietf | 32 | 12 |
des-cfb | 8 | 8 |
idea-cfb | 16 | 8 |
rc2-cfb | 16 | 8 |
16 | 0 | |
rc4-md5 | 16 | 16 |
salsa20 | 32 | 8 |
seed-cfb | 16 | 16 |
安装m2crypto可以加快一点加密速度
apt-get install python-m2crypto
启动和停止
前台运行命令:
ssserver -c /etc/shadowsocks.json
后台运行命令:
ssserver -c /etc/shadowsocks.json -d start
ssserver -c /etc/shadowsocks.json -d stop
都需要指定配置文件的路径。启动后可以在系统中查看:
chengchao@189554:~$ ps -aux | grep ssserver
root 5034 0.0 0.9 47676 9340 ? Ss Jan16 2:37 /usr/bin/python /usr/local/bin/ssserver -c /etc/shadowsocks.json -d start
也可以查看Log,检查SS的状态
tail -f /var/log/shadowsocks.log
输出log如下:
2017-01-30 14:52:59 INFO connecting s2.googleusercontent.com:443 from 59.172.28.64:37629
2017-01-30 14:52:59 INFO connecting s2.googleusercontent.com:443 from 59.172.28.64:37627
2017-01-30 14:52:59 INFO connecting s2.googleusercontent.com:443 from 59.172.28.64:37626
2017-01-30 14:52:59 INFO connecting s2.googleusercontent.com:443 from 59.172.28.64:37625
2017-01-30 14:52:59 INFO connecting s2.googleusercontent.com:443 from 59.172.28.64:37630
2017-01-30 14:52:59 INFO connecting s2.googleusercontent.com:443 from 59.172.28.64:37628
2017-01-30 14:57:45 WARNING timed out: shadowsocks.org:443
2017-01-30 14:58:46 INFO connecting clients4.google.com:443 from 59.172.28.64:37979
2017-01-30 14:59:33 INFO connecting clients4.google.com:443 from 59.172.28.64:38113
2017-01-30 14:59:40 INFO connecting mtalk.google.com:5228 from 59.172.28.64:38130
开机启动
在/etc/rc.local中加入
#start the shadowsocks server
sudo ssserver -c /etc/shadowsocks.json -d start
0 条评论