1. 安装 python
2. 安装 pip
如果 python-pip 找不到,则需要先安装 epel 扩展源,然后再安装 python-pip 就可以了
| yum -y install epel-release yum install python-pip
|
3. 安装 Shadowsocks
4. 配置 Shadowsocks
创建文件 /etc/shadowsocks.json ,内容如下:
| { "server":"0.0.0.0", "server_port":8388, "local_port":1080, "password":"12345678", "timeout":600, "method":"aes-256-cfb" }
|
说明:
- method为加密方法,可选aes-128-cfb, aes-192-cfb, aes-256-cfb, bf-cfb, cast5-cfb, des-cfb, rc4-md5, chacha20, salsa20, rc4, table
- server_port 为服务监听端口, 这个需要在 vultr或者服务器管理界面开启
- port_password 为多用户的时候,配置的 port: pass 的json串
5. 配置自启动
新建启动脚本文件 /etc/systemd/system/shadowsocks.service ,内容如下:
| [Unit] Description=Shadowsocks
[Service] TimeoutStartSec=0 ExecStart=/usr/bin/ssserver -c /etc/shadowsocks.json
[Install] WantedBy=multi-user.target
|
执行以下命令启动 Shadowsocks 服务:
| systemctl enable shadowsocks
systemctl start shadowsocks
systemctl status shadowsocks
systemctl stop shadowsocks
|
6. CentOS 开放端口
| firewall-cmd --zone=public --add-port=8388/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --list-ports
|
使用脚本自动部署
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 40 41 42 43 44 45 46 47
| echo "centos7 shadowsocks deploy!"
yum install python
yum -y install epel-release yum install python-pip
pip install shadowsocks
echo '{ "server":"0.0.0.0", "server_port":8388, "local_port":1080, "password":"12345678", "timeout":600, "method":"aes-256-cfb" }' > /etc/shadowsocks.json
echo '[Unit] Description=Shadowsocks [Service] TimeoutStartSec=0 ExecStart=/usr/bin/ssserver -c /etc/shadowsocks.json [Install] WantedBy=multi-user.target' > /etc/systemd/system/shadowsocks.service
systemctl enable shadowsocks
systemctl start shadowsocks
systemctl status shadowsocks
firewall-cmd --zone=public --add-port=8388/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --list-ports
echo "finish!"
|
本文参考:
https://www.4spaces.org/install-shadowsocks-on-centos-7/
https://www.4spaces.org/centos-open-porter/