Shadowsocks Python版一键安装脚本

发布时间: 更新时间: 总字数:966 阅读时间:2m 作者:IP:上海 网址
专栏文章
  1. alpine 部署 v2ray 服务
  2. Clash 使用
  3. Hysteria 2 介绍
  4. Mitmproxy HTTPS 代理工具
  5. WireGuard VPN 安装和使用
  6. Inode VPN 使用
  7. V2ray 介绍
  8. Shadowsocks Python版一键安装脚本(当前)
  9. OpenVPN client 使用问题
  10. OpenVPN server 配置文件详细说明
  11. CentOS 6/7 安装配置 OpenVPN Server
  12. CentOS 架设PPTP VPN服务教程

本文介绍 Shadowsocks Python 版一键安装脚本,以及在 Windows/Linux 环境安装部署 client 使用方法。

服务器端安装

适用环境

  • 系统支持:CentOS 6,7,Debian,Ubuntu
  • 内存要求:≥128M

关于本脚本

一键安装 Python 版 Shadowsocks 的最新版:https://github.com/teddysun/shadowsocks_install

默认配置

  • 服务器端口:自己设定(如不设定,默认从 9000-19999 之间随机生成)
  • 密码:自己设定
  • 加密方式:自己设定(如不设定,默认为 aes-256-gcm)

备注:脚本默认创建单用户配置文件,如需配置多用户,安装完毕后参照下面的教程示例手动修改配置文件后重启即可。

安装方法

使用 root 用户登录,运行以下命令:

bash
wget --no-check-certificate -O shadowsocks.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks.sh
chmod +x shadowsocks.sh
./shadowsocks.sh 2>&1 | tee shadowsocks.log

安装完成后,脚本提示如下:

text
Congratulations, Shadowsocks-python server install completed!
Your Server IP        :your_server_ip
Your Server Port      :your_server_port
Your Password         :your_password
Your Encryption Method:your_encryption_method

Welcome to visit:https://teddysun.com/342.html
Enjoy it!

配置安全组规则:

bash
iptables -I INPUT -p tcp -m tcp --dport 9958 -j ACCEPT
service iptables save

卸载方法

使用 root 用户登录,运行以下命令:

bash
./shadowsocks.sh uninstall

单用户配置文件示例,配置文件路径:/etc/shadowsocks.json

json
{
    "server":"0.0.0.0",
    "server_port":your_server_port,
    "local_address":"127.0.0.1",
    "local_port":1080,
    "password":"your_password",
    "timeout":300,
    "method":"your_encryption_method",
    "fast_open": false
}

多用户多端口配置文件示例,配置文件路径:/etc/shadowsocks.json

json
{
    "server":"0.0.0.0",
    "local_address":"127.0.0.1",
    "local_port":1080,
    "port_password":{
         "8989":"password0",
         "9001":"password1",
         "9002":"password2",
         "9003":"password3",
         "9004":"password4"
    },
    "timeout":300,
    "method":"your_encryption_method",
    "fast_open": false
}

使用命令

  • 启动:/etc/init.d/shadowsocks start
  • 停止:/etc/init.d/shadowsocks stop
  • 重启:/etc/init.d/shadowsocks restart
  • 状态:/etc/init.d/shadowsocks status

客户端安装

Windows

text
https://github.com/shadowsocks/shadowsocks-windows/releases

Linux

Debian/Ubuntu:

bash
apt-get install python-pip
pip install shadowsocks

CentOS:

bash
yum install python-setuptools && easy_install pip
pip install shadowsocks

创建 shadowsocks 的配置文件,一般放到 /etc 下面:

bash
sudo vim /etc/shadowsocks.json
json
{
  "server":"my_server_ip",
  "server_port":my_server_port,
  "local_address": "127.0.0.1",
  "local_port":1080,
  "password":"my_password",
  "timeout":300,
  "method":"aes-256-cfb"
}

配置说明:

  • my_server_ip 改为自己的服务器 IP
  • my_server_port 改为自己的服务器端口
  • my_server_password 改为自己的密码
  • method 的值改为自己的加密方式,一般是 aes-256-cfb 或者 rc4-md5

开机启动:

bash
sudo vim /etc/systemd/system/shadowsocks.service
ini
[Unit]
Description=Shadowsocks Client Service
After=network.target

[Service]
Type=simple
User=root
ExecStart=/usr/local/bin/sslocal -c /etc/shadowsocks.json

[Install]
WantedBy=multi-user.target

生效:

bash
systemctl enable /etc/systemd/system/shadowsocks.service

启动:

bash
systemctl start /etc/systemd/system/shadowsocks.service

浏览器代理

安装 SwitchyOmega 插件

以 Chrome 为例,安装 SwitchyOmega 插件代理,Github 下载 SwitchyOmega:

text
https://github.com/FelisCatus/SwitchyOmega/releases/

Chrome 打开chrome://extensions/,把插件托进去安装。

配置 Proxy:

  • Server 填写 shadowsocks.json 配置中的 local_address
  • Port 填写 shadowsocks.json 配置中的 local_port
  • 左边 Apply changes 保存

配置 Auto Switch:

  • Rule list rules 的 Profile 填 proxy
  • Default 的 Profile 填[Direct]
  • Rule List Format 选择 AutoProxy
  • Rule List URL 填写 gfwlist 的规则:
text
https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt
  • 下载规则文件 Download Profile Now
  • 左边 Apply changes 保存

问题

谷歌 chrome 浏览器 同步 Request canceled 自动切换模式下 Chrome 无法登陆谷歌账户

添加规则

text
*.googleapis.com +proxy

之后便可正常登陆