在VPS上部署shadowsocks,推荐使用C语言编译的libev版本的服务端。下面介绍在Linux系统的VPS上安装并配置的方法。Linux请采用近期的发行版,不要过老。本文基本是照着github上的readme翻译的,给那些英文苦手一点帮助。
如本篇内容有问题,请以shadowsocks-libev的Github为准:
https://github.com/shadowsocks/shadowsocks-libev
一、安装shadowsocks服务端
1. 从源码编译安装
Ubuntu/Debian:
先安装必须的包:
|
apt-get install --no-install-recommends build-essential autoconf libtool libssl-dev \
gawk debhelper dh-systemd init-system-helpers pkg-config asciidoc xmlto apg
|
然后通过git下载源码:
|
git clone https://github.com/shadowsocks/shadowsocks-libev.git
|
然后生成deb包并安装,一步步执行(留意是否出错 如果出错需要检查系统或者之前的步骤):
|
cd shadowsocks-libev
dpkg-buildpackage -us -uc
cd ..
dpkg -i shadowsocks-libev*.deb
|
其他Unix-like的系统,特别是Debian-based的Linux发行版如: Ubuntu, Debian or Linux Mint
|
apt-get install build-essential autoconf libtool libssl-dev
git clone https://github.com/madeye/shadowsocks-libev.git
cd shadowsocks-libev
./configure
make
make install
|
2. 直接从作者提供的软件源安装(Ubuntu/Debian)
由于作者更新源码后并不一定更新这些预编译的包,所以无法保证最新版本,但步骤比较简单。不推荐这种方式。
先添加GPG Key:
|
wget -O- http://shadowsocks.org/debian/1D27208A.gpg | sudo apt-key add -
|
Ubuntu 12.04 / Debian Wheezy以上版本(libssl 1.0.1以上):
在/etc/apt/sources.list末尾添加:
|
deb http://shadowsocks.org/debian wheezy main
|
Ubuntu 11.04 / Debian Squeeze(libssl 0.9.8~1.0.0):
在/etc/apt/sources.list末尾添加:
|
deb http://shadowsocks.org/debian squeeze main
|
最后安装
|
apt-get update
apt-get install shadowsocks-libev
|
二、配置与启动
1、配置文件为:/etc/shadowsocks-libev/config.json,格式说明:
|
{
"server":"example.com or X.X.X.X",
"server_port":443,
"password":"password",
"method":"rc4-md5",
"timeout":60
}
|
其中:
server:主机域名或者IP地址,尽量填IP
server_port:服务器监听端口
password:密码
method:加密方式 默认为table,其他有rc4,rc4-md5,aes-128-cfb, aes-192-cfb, aes-256-cfb,bf-cfb, camellia-128-cfb, camellia-192-cfb,camellia-256-cfb, cast5-cfb, des-cfb
如果客户端有OpenWRT路由器等设备,推荐rc4-md5,性能更好;否则可以选用安全性更好的aes-256-cfb等,不过计算复杂度上升,会有性能的损失,不过对于PC机以及现在的只能手机来说没有任何问题。路由器性能较弱所以可以考虑rc4-md5。
timeout:连接超时时间,单位秒。要适中。
注意引号。
2、启动
Ubuntu/Debian 通过deb包安装的(deb包安装的默认会开启自启):
|
service shadowsocks-libev restart
|
CentOS,拷贝启动脚本shadowsocks-libev到/etc/init.d/目录下后,启动:
|
/etc/init.d/shadowsocks-libev start
|
需要开机自启的,可以建立符号连接到/etc/rc.d/SXXshadowsocks-libev
或者直接调用ss-server命令运行,具体用法如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
usage:
ss-[local|redir|server|tunnel]
-s <server_host> host name or ip address of your remote server
-p <server_port> port number of your remote server
-l <local_port> port number of your local server
-k <password> password of your remote server
[-m <encrypt_method>] encrypt method: table, rc4, rc4-md5
aes-128-cfb, aes-192-cfb, aes-256-cfb,
bf-cfb, camellia-128-cfb, camellia-192-cfb,
camellia-256-cfb, cast5-cfb, des-cfb,
idea-cfb, rc2-cfb and seed-cfb
[-f <pid_file>] file to store the pid
[-t <timeout>] socket timeout in seconds
[-c <config_file>] config file in json
[-i <interface>] network interface to bind,
not available in redir mode
[-b <local_address>] local address to bind,
not available in server mode
[-u] enable udprelay mode
not available in redir mode
[-L <addr>:<port>] setup a local port forwarding tunnel,
only available in tunnel mode
[-v] verbose mode
[--fast-open] enable TCP fast open,
only available on Linux kernel > 3.7.0
[--acl <acl_file>] config file of ACL (Access Control List)
notes:
ss-redir provides a transparent proxy function and only works on the
Linux platform with iptables.
|
一个例子如:
|
setsid ss-server -c /etc/shadowsocks/config.json -u
|
查看shadowsocks是否正确启动并监听相应端口,看到有ss-server进程LISTEN正确的端口就表示成功:
如果您还未购买将要购买国外VPS搭建shadowsocks,这里为您推荐几家VPS提供商,详情见《关于本站》页面。