SS服务端部署教程

clowwindy写的Python服务端版本已经停止更新,不建议使用。目前仍处于活跃开发的服务端版本有libev(C语言)go(两个)和rust。相对于原版,这几个版本占用资源少,性能更好,推荐使用。

下文以libev版(目前最广泛使用的版本)说一下服务器端的部署,前提是你有一台境外服务器。CentOS/Fedora/RHEL系统建议从librehat维护的官方源安装SS。librehat是SS多个项目的核心贡献者,其中文博客:https://www.librehat.com/。其他系统的安装和使用请参考libev项目:https://github.com/shadowsocks/shadowsocks-libev

在CentOS 7下安装libev版的步骤是:

  1. https://copr.fedorainfracloud.org/coprs/librehat/shadowsocks/下载软件源配置文件放到/etc/yum.repos.d目录下:

    wget -O /etc/yum.repos.d/librehat-shadowsocks-epel-7.repo 'https://copr.fedorainfracloud.org/coprs/librehat/shadowsocks/repo/epel-7/librehat-shadowsocks-epel-7.repo'
    
  2. yum安装libev版的SS:

    yum install -y shadowsocks-libev
    

接下来编辑/etc/shadowsocks-libev/config.json配置文件,主要是填写端口号和密码。单用户配置文件为:

{
    "server":"0.0.0.0",
    "server_port":35697,
    "local_port":1080,
    "password":"#SADFas890as@#ASD",
    "timeout":60,
    "method":"aes-256-cfb",
    "fastopen": true
}

关于加密算法的选择,个人建议使用AES-256-CFB。原因是加密强度足够高,并且几乎所有的客户端都支持(许多客户端不支持gcm类算法)。一些加密算法,例如table和RC4,因安全性不够,不建议使用。

配置好后,设置开机启动:

systemctl enable shadowsocks-libev && systemctl start shadowsocks-libev

注意:多用户配置应该使用ss-manager命令(ss-server不会识别多用户的配置),对应的配置文件是/etc/shadowsocks-libev/manager.json。一个多用户的配置示例:

{
    "server":"0.0.0.0",
    "local_port":1080,
    "timeout":60,
    "port_password": {
        "8080":"mima1",
        "8081":"mima2"
    },
    "method":"aes-256-cfb",
    "fastopen": true
}

后台执行的命令是:nohup ss-manager -c /etc/shadowsocks-libev/manager.json > /dev/null 2>&1 &

如果开启了防火墙,记得将SS的端口放行。

除了部署服务端,强烈建议安装bbr模块加快网速。CentOS 7上的安装教程请参考:CentOS 7开启BBR

SS客户端

根据操作系统不同,各个平台的客户端下载地址如下:

  1. Windows/PC,官方Github项目地址:https://github.com/shadowsocks/shadowsocks-windows,编译好的exe下载地址:https://github.com/shadowsocks/shadowsocks-windows/releases
  2. Mac: 官方Github地址:https://github.com/shadowsocks/ShadowsocksX-NG,编译好的安装包下载地址:https://github.com/shadowsocks/ShadowsocksX-NG/releases
  3. android/安卓:官方Github地址:https://github.com/shadowsocks/shadowsocks-android,编译好的APK地址:https://github.com/shadowsocks/shadowsocks-android/releases
  4. 跨平台libQtShadowsocks或者shadowsocks-qt5,有可能需要自行编译。

donation