Across the Great Wall we can reach every corner in the world.

1. 安装 shadowsocks

:为了支持chacha20-ietf-poly1305加密方式,请勿直接使用pip install shadowsocks,而是要通过zip包安装,如下所示

# 安装依赖
> yum install epel-release python-pip libsodium

# 也可将 zip 包先下载到本地再安装
> pip install https://github.com/shadowsocks/shadowsocks/archive/master.zip -U 

> sslocal --version
Shadowsocks 3.0.0

2. 修改配置文件

> mkdir -p /etc/shadowsocks
> vim /etc/shadowsocks/config.json

添加如下内容:

{
    "server": "x.x.x.x",          # Server IP
    "server_port": 14131,         # Server Port
    "local_address": "127.0.0.1", # Local IP
    "local_port": 1080,           # Local Port
    "password": "password",       # Your Password
    "timeout": 600,               # Connection timeout
    "method": "aes-256-cfb",      # Encryption method
    "fast_open": false,           # Use TCP_FASTOPEN, requires Linux 3.7+
    "workers": 1                  # Number of worker threads
}

3. 配置服务

> vim /etc/systemd/system/shadowsocks.service

添加如下内容:

[Unit]
Description=Shadowsocks

[Service]
TimeoutStartSec=0
ExecStart=/usr/bin/sslocal -c /etc/shadowsocks/config.json

[Install]
WantedBy=multi-user.target

4. 启动 shadowsocks 并配置自启动

启动shadowsocks

> systemctl start shadowsocks.service

> systemctl status shadowsocks.service
● shadowsocks.service - Shadowsocks
   Loaded: loaded (/etc/systemd/system/shadowsocks.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2020-02-03 12:08:31 CST; 18min ago
 Main PID: 28122 (sslocal)
    Tasks: 1
   Memory: 7.1M
   CGroup: /system.slice/shadowsocks.service
           └─28122 /usr/bin/python2 /usr/bin/sslocal -c /etc/shadowsocks/config.json

根据实际需要配置服务自启动

> systemctl is-enabled shadowsocks.service 
disabled

> systemctl enable shadowsocks.service

5. 使用 ProxyChains 代理终端流量

参见 Linux 下使用 SSR + ProxyChains 代理终端流量

6. 测试连接

> curl --socks5 127.0.0.1:1080 http://httpbin.org/ip
{
  "origin": "xxx.xxx.xxx.xxx"
}

> pc curl myip.ipip.net
[proxychains] config file found: /etc/proxychains.conf
[proxychains] preloading /usr/lib/libproxychains4.so
[proxychains] DLL init: proxychains-ng 4.14-git-8-gb8fa2a7
[proxychains] Strict chain  ...  127.0.0.1:1080  ...  myip.ipip.net:80  ...  OK
当前 IP:xxx.xxx.xxx.xxx  来自于:日本 东京都 东京  xx.net

参考文章

  1. CentOS 7 安装配置 Shadowsocks 客户端 | Dylan
  2. Shadowsocks 原理简介及安装指南 | 小胡子哥
  3. CentOS 7 安装 shadowsocks 客户端 | 全栈渐进之路
  4. 在 CentOS 7 下安装配置 shadowsocks | 早起搬砖 morning.work
  5. Linux 下使用 SSR + ProxyChains 代理终端流量 | 苏易北
  6. proxychains-ng | Github