Shadowsocks 一键安装脚本(四合一)

技术 秋水逸冰 3784926浏览 1374评论

本脚本适用环境

系统支持:CentOS 6+,Debian 7+,Ubuntu 12+
内存要求:≥128M
日期  :2019 年 01 月 11 日

关于本脚本

1、一键安装 Shadowsocks-Python, ShadowsocksR, Shadowsocks-Go, Shadowsocks-libev 版(四选一)服务端;
2、各版本的启动脚本及配置文件名不再重合;
3、每次运行可安装一种版本;
4、支持以多次运行来安装多个版本,且各个版本可以共存(注意端口号需设成不同);
5、若已安装多个版本,则卸载时也需多次运行(每次卸载一种);

友情提示:如果你有问题,请先阅读这篇《Shadowsocks Troubleshooting》之后再询问。

默认配置

服务器端口:自己设定(如不设定,默认从 9000-19999 之间随机生成)
密码:自己设定(如不设定,默认为 teddysun.com)
加密方式:自己设定(如不设定,Python 和 libev 版默认为 aes-256-gcm,R 和 Go 版默认为 aes-256-cfb)
协议(protocol):自己设定(如不设定,默认为 origin)(仅限 ShadowsocksR 版)
混淆(obfs):自己设定(如不设定,默认为 plain)(仅限 ShadowsocksR 版)
备注:脚本默认创建单用户配置文件,如需配置多用户,请手动修改相应的配置文件后重启即可。

客户端下载

常规版 Windows 客户端
https://github.com/shadowsocks/shadowsocks-windows/releases

ShadowsocksR 版 Windows 客户端
https://github.com/shadowsocksrr/shadowsocksr-csharp/releases

使用方法

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

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

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

Congratulations, your_shadowsocks_version install completed!
Your Server IP        :your_server_ip
Your Server Port      :your_server_port
Your Password         :your_password
Your Encryption Method:your_encryption_method

Your QR Code: (For Shadowsocks Windows, OSX, Android and iOS clients)
 ss://your_encryption_method:your_password@your_server_ip:your_server_port
Your QR Code has been saved as a PNG file path:
 your_path.png

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

卸载方法

若已安装多个版本,则卸载时也需多次运行(每次卸载一种)

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

./shadowsocks-all.sh uninstall

启动脚本

启动脚本后面的参数含义,从左至右依次为:启动,停止,重启,查看状态。

Shadowsocks-Python 版:
/etc/init.d/shadowsocks-python start | stop | restart | status

ShadowsocksR 版:
/etc/init.d/shadowsocks-r start | stop | restart | status

Shadowsocks-Go 版:
/etc/init.d/shadowsocks-go start | stop | restart | status

Shadowsocks-libev 版:
/etc/init.d/shadowsocks-libev start | stop | restart | status

各版本默认配置文件

Shadowsocks-Python 版:
/etc/shadowsocks-python/config.json

ShadowsocksR 版:
/etc/shadowsocks-r/config.json

Shadowsocks-Go 版:
/etc/shadowsocks-go/config.json

Shadowsocks-libev 版:
/etc/shadowsocks-libev/config.json

更新日志

2019 年 01 月 11 日:
1、升级:libsodium 到最新版本 1.0.17;
2、升级:mbedtls 到最新版本 2.16.0;

2018 年 11 月 05 日:
1、升级:使用 Github 上最新代码编译出 Go 版二进制可执行文件,版本号 1.2.2。

2018 年 06 月 01 日:
1、修正:在启用了插件 simple-obfs 的情况下,libev 版启动失败的问题;
2、修正:在使用 /etc/init.d/shadowsocks-libev restart 命令重启 libev 版服务端时,偶尔出现的 “bind: Address already in use” 问题;
3、修正:移除 libev 版配置文件中的 local_address 字段;
4、修改:不再默认使用 root 用户启动,改为使用 nobody 用户启动 libev 版服务端 ss-server;
5、升级:mbedtls 到版本 2.9.0;
6、修改:libev 版启动脚本中的 -u 参数(即同时启用 TCP 和 UDP 模式),改到配置文件里配置为 “mode”: “tcp_and_udp”;
7、修改:libev 版配置文件的内置 NameServers 为 8.8.8.8,默认是从 /etc/resolv.conf 中取得。

2018 年 02 月 07 日:
1、修改:将默认端口从 8989 改为从 9000-19999 之间随机生成。

2018 年 02 月 06 日:
1、修改:ShadowsocksR 版为 ShadowsocksRR 最新版;
2、新增:ShadowsocksR 版的协议(protocol)增加了 4 个,分别为:

auth_chain_c
auth_chain_d
auth_chain_e
auth_chain_f

2017 年 12 月 29 日:
1、升级:libsodium 到 1.0.16。

2017 年 11 月 25 日:
1、如果 Linux 内核版本大于 3.7.0,则配置文件默认支持 TCP fast open;
2、新增:libev 版启动时支持 verbose mode,也就是默认写 log 到 /var/log/messages 方便查看。

2017 年 11 月 12 日:
1、新增生成 ss:// 或 ssr:// 链接,以及其二维码图片。
※ 脚本会根据当前安装的版本以及输入的各项配置,自动生成 ss:// 或 ssr:// 的链接并在安装成功后显示,直接复制即可被客户端识别。同时生成其二维码图片,并保存在当前目录下,下载后用看图软件打开,也能被客户端识别。

复制二维码链接后 Shadowsocks 客户端识别示例:

复制二维码链接后 ShadowsocksR 客户端识别示例:

二维码(QR Code)参考链接:
https://github.com/shadowsocks/shadowsocks/wiki/Generate-QR-Code-for-Android-or-iOS-Clients
https://github.com/shadowsocksr-backup/shadowsocks-rss/wiki/SSR-QRcode-scheme

2017 年 10 月 22 日:
1、升级:libsodium 到 1.0.15。

2017 年 10 月 14 日:
1、新增:在安装 Shadowsocks-libev 版时可选安装 simple-obfs 服务端。
※ 脚本通过判断 autoconf 版本是否大于或等于 2.67 来一键安装 simple-obfs 服务端。并且,支持在安装过程中选择 obfs 为 http 或 tls。
※ 使用方法参考:https://teddysun.com/511.html

2017 年 09 月 16 日:
1、修正:Shadowsocks-libev 版 v3.1.0 使用 libc-ares 替换 libudns 依赖包,解决了依赖问题;
2、升级:mbedtls 到版本 2.6.0。

2017 年 07 月 27 日:
1、新增:ShadowsocksR 版可选协议(protocol)auth_chain_b 。使用该协议需更新到最新(4.7.0) ShadowsocksR 版客户端
2、修改:更新 ShadowsocksR 源码下载地址。

2017 年 07 月 23 日:
1、修正:卸载时可自行选择某个版本卸载,若该版本不存在则报错退出。

2017 年 07 月 22 日:
1、修正:默认加密方式从 aes-256-cfb 改为 aes-256-gcm(Python 和 libev 版);
2、新增:安装时可选 16 种加密方式的其中之一(Python 和 libev 版)。如下所示:

aes-256-gcm
aes-192-gcm
aes-128-gcm
aes-256-ctr
aes-192-ctr
aes-128-ctr
aes-256-cfb
aes-192-cfb
aes-128-cfb
camellia-128-cfb
camellia-192-cfb
camellia-256-cfb
chacha20-ietf-poly1305
chacha20-ietf
chacha20
rc4-md5

3、新增:安装时可选 9 种加密方式的其中之一(Go 版)。如下所示:

aes-256-cfb
aes-192-cfb
aes-128-cfb
aes-256-ctr
aes-192-ctr
aes-128-ctr
chacha20-ietf
chacha20
rc4-md5

4、新增:安装时可选 15 种加密方式的其中之一(none 是不加密,ShadowsocksR 版)。如下所示:

none
aes-256-cfb
aes-192-cfb
aes-128-cfb
aes-256-cfb8
aes-192-cfb8
aes-128-cfb8
aes-256-ctr
aes-192-ctr
aes-128-ctr
chacha20-ietf
chacha20
salsa20
xchacha20
xsalsa20
rc4-md5

5、新增:安装时可选 7 种协议(protocol)的其中之一(仅限 ShadowsocksR 版)。如下所示:

origin
verify_deflate
auth_sha1_v4
auth_sha1_v4_compatible
auth_aes128_md5
auth_aes128_sha1
auth_chain_a
auth_chain_b

6、新增:安装时可选 9 种混淆(obfs)的其中之一(仅限 ShadowsocksR 版)。如下所示:

plain
http_simple
http_simple_compatible
http_post
http_post_compatible
tls1.2_ticket_auth
tls1.2_ticket_auth_compatible
tls1.2_ticket_fastauth
tls1.2_ticket_fastauth_compatible

2017 年 02 月 24 日:
1、恢复: 通过 Github API 自动获取 Shadowsocks-libev 的最新 release 版本的功能(v3.0.3)。

2017 年 02 月 13 日:
1、升级: Shadowsocks-libev 版到版本 3.0.2;
2、升级: Shadowsocks-go 版到版本 1.2.1(基于 Github 最新代码,用 go 1.8 编译完成的 x86 和 x86_64 二进制文件);
3、修复:在 Debian 7 下默认没有 libudns-dev 依赖包的问题。

2017 年 02 月 12 日:
1、升级: Shadowsocks-libev 版到版本 3.0.1。

2017 年 01 月 27 日:
1、升级: Shadowsocks-go 版到版本 1.2.1 (仅适用于 x86_64 系统)

更多单版本 Shadowsocks 服务端一键安装脚本

Shadowsocks Python 版一键安装脚本(CentOS,Debian,Ubuntu)
ShadowsocksR 版一键安装脚本(CentOS,Debian,Ubuntu)
CentOS 下 Shadowsocks-libev 一键安装脚本
Debian 下 Shadowsocks-libev 一键安装脚本
Shadowsocks-go 一键安装脚本(CentOS,Debian,Ubuntu)

注意:以上单版本不可与该四合一版本混用。

转载请注明:秋水逸冰 » Shadowsocks 一键安装脚本(四合一)

发表我的评论
取消评论

请输入正确答案后提交评论 *超出时限。 请再次填写验证码。

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (1374)

  1. ss_local-aead.o: In function `aead_cipher_decrypt': /root/shadowsocks-libev-3.1.3/src/aead.c:219: undefined reference to `crypto_aead_xchacha20poly1305_ietf_decrypt' ss_local-aead.o: In function `aead_cipher_encrypt': /root/shadowsocks-libev-3.1.3/src/aead.c:180: undefined reference to `crypto_aead_xchacha20poly1305_ietf_encrypt' collect2: error: ld returned 1 exit status Makefile:677: recipe for target 'ss-local' failed 編譯失敗. 哥們能不能改改編譯腳本每次取得確定版本的 ss-libev 源代碼, 而不是當前的開發分支. 避免錯誤. 我的編譯環境是 debian 9.
    路過6年前(2018-01-23)回复
  2. wget --no-check-certificate -O shadowsocks-all.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-all.sh chmod +x shadowsocks-all.sh ./shadowsocks-all.sh 2>&1 | tee shadowsocks-all.log 输入如上就这样了,下载不到? wget --no-check-certificate -O shadowsocks-all.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-all.sh chmod +x shadowsocks-all.sh ./shadowsocks-all.sh 2>&1 | tee shadowsocks-all.log
    老闸门6年前(2018-01-23)回复
    • libev版本一连接就自动结束进程
      006年前(2018-01-23)回复
  3. 昨天都可以,今天装第一步就提示如下,幸苦大佬解答一下安装系统是Centos 7 x86_64 -bash: ./shadowsocks-go.sh: No such file or directory
    luke6年前(2018-01-22)回复
    • 是./shadowsocks-all.sh啊大佬
      AM6年前(2018-01-23)回复
  4. 大神,求问个基本性的问题。 由于兴趣,我也尝试着购买了一个阿里的ecs云,然后看着你的ss教程和走了一遍,结果该显示的也都显示成功了。(查状态是运行中) 但是,当我用ss客户端,打算连接的时候,客户端这边的log总是显示连接超时。 阿里云给我的外网ip,我在自己的计算机上肯定也是没法直接ping通的,在专门的网站上ping后,是部分能ping通,不分不行。 求问我该如何调试或是解决当前的情况? (远程连接部分我直接用了阿里页面自带的远程连接,没有下载putty之类用于远程连接的软件)
    惊了绝了勃了6年前(2018-01-22)回复
    • 从你问的问题现象来看,你是打算让我猜一下原因么? 我觉得首先在你本地能 ping 的通才是最基本的吧。
      秋水逸冰6年前(2018-01-22)回复
      • 开了2G的虚拟内存,总算跑完了
        AM6年前(2018-01-23)回复
      • 那如果本地ping不通了是不是只能去找阿里客服之类的了,我去询问下看看。
        惊了绝了勃了6年前(2018-01-23)回复
  5. 怎么总是卡在gzip这一步 第一次提示: Error downloading packages: gzip-1.5-9.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory [Error] Failed to install gzip Please visit: https://teddysun.com/486.html and contact. 手动安装gzip被杀进程 # yum install -y gzip Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos-distro.cavecreek.net * epel: mirrors.develooper.com * extras: repos.dfw.quadranet.com * updates: linux.mirrors.es.net Resolving Dependencies --> Running transaction check ---> Package gzip.x86_64 0:1.5-8.el7 will be updated ---> Package gzip.x86_64 0:1.5-9.el7 will be an update Killed 大佬何解啊?
    AM6年前(2018-01-22)回复
    • Cannot allocate memory 这句话表示内存不足,是不是你的 VPS 内存太小的缘故?
      秋水逸冰6年前(2018-01-22)回复
  6. 直接用搬瓦工的vps根本不用自己配置开启即可
    thornbird6年前(2018-01-22)回复
  7. 请问在pc和iphone6s上 aes-256-cfb aes-256-gcm和chacha20-ietf-poly1305 三种加密方式哪个速度更快些? 网上有不同的说法
    jaleo6年前(2018-01-21)回复
    • 个人使用的话,任选一种都行。我没评测过各种加密方式的效率问题。
      秋水逸冰6年前(2018-01-22)回复
    • aes 256 gcm电脑上用 最后一个 手机上用。
      beibei6年前(2018-01-24)回复
  8. 装了半天都不好使,仔细一瞅我的centos 7没开firewall,用的是iptabel config_firewall() { if centosversion 6; then /etc/init.d/iptables status > /dev/null 2>&1 if [ $? -eq 0 ]; then iptables -L -n | grep -i ${shadowsocksport} > /dev/null 2>&1 if [ $? -ne 0 ]; then iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${shadowsocksport} -j ACCEPT iptables -I INPUT -m state --state NEW -m udp -p udp --dport ${shadowsocksport} -j ACCEPT /etc/init.d/iptables save /etc/init.d/iptables restart else echo -e "[${green}Info${plain}] port ${green}${shadowsocksport}${plain} already be enabled." fi else echo -e "[${yellow}Warning${plain}] iptables looks like not running or not installed, please enable port ${shadowsocksport} manually if necessary." fi elif centosversion 7; then systemctl status firewalld > /dev/null 2>&1 if [ $? -eq 0 ]; then firewall-cmd --permanent --zone=public --add-port=${shadowsocksport}/tcp firewall-cmd --permanent --zone=public --add-port=${shadowsocksport}/udp firewall-cmd --reload else echo -e "[${yellow}Warning${plain}] firewalld looks like not running or not installed, please enable port ${shadowsocksport} manually if necessary." fi fi }
    AM6年前(2018-01-21)回复
    • 脚本没有处理这种在 CentOS 7 里安装 iptables 的情况。 不过既然你在 CentOS 7 里不用 firewalld 而是使用 iptables,就表示你自己会使用 iptables 手动开启相应端口。
      秋水逸冰6年前(2018-01-22)回复
      • 跟我没关系啊,这家的主机centos7就是默认开iptable,一开始不知道,我都快郁闷死了,装完ss了死活连不上,看日志也没错误
        AM6年前(2018-01-23)回复
  9. 大佬 请问一下为什么配置好的$$R 只能电脑用 手机用时显示没网络
    dfgd6年前(2018-01-20)回复
    • 这种玄学问题我是猜不出来滴。下次问问题的时候呢,请尽量描述清楚现象,系统,配置等等有用的信息。
      秋水逸冰6年前(2018-01-22)回复
  10. 秋大 VPS换了IP ,请教如何更新SSR链接地址和二维码图片。 谢谢
    ahfncj6年前(2018-01-20)回复
    • 脚本在安装完成的时候会根据当前的IP地址自动生成SSR链接和二维码图片。如有必要,重装即可。
      秋水逸冰6年前(2018-01-20)回复
      • 谢谢 秋大
        ahfncj6年前(2018-01-20)回复
  11. [root@mario ss]# wget --no-check-certificate -O shadowsocks.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks.sh --2018-01-18 23:52:16-- https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks.sh Resolving raw.githubusercontent.com... 151.101.0.133, 151.101.64.133, 151.101.128.133, ... Connecting to raw.githubusercontent.com|151.101.0.133|:443... failed: Connection timed out. Connecting to raw.githubusercontent.com|151.101.64.133|:443... failed: Connection timed out. Connecting to raw.githubusercontent.com|151.101.128.133|:443... failed: Connection timed out. Connecting to raw.githubusercontent.com|151.101.192.133|:443... 秋水大神,这是服务器问题,还是链接的问题?
    mario6年前(2018-01-19)回复
    • 这是你的服务器连不上 Github 导致的。
      秋水逸冰6年前(2018-01-19)回复
  12. 秋水,今天发现shadowsocks不能用了.我用Xshell可以登录vultr的Debian,而且ping墙外的都还可以用. 但是本机用shadowsocks就没反应了.
    Jesse6年前(2018-01-19)回复
    • 可能是 IP 被墙了。
      秋水逸冰6年前(2018-01-19)回复
      • 可谓是请问为什么 IP 被抢了, 还可以用 Xshell 登陆呢?
        Ptsed6年前(2018-01-20)回复
  13. 你好,小白想知道,我想在手机上和电脑上用不同的加密,该怎么配置。因为我不想在手机上使用aes 256 gcm
    beibei6年前(2018-01-18)回复
  14. Reading package lists... Done Building dependency tree Reading state information... Done You might want to run 'apt-get -f install' to correct these: The following packages have unmet dependencies: libsodium-dev : Depends: libsodium13 (= 1.0.0-1) but it is not going to be inst alled shadowsocks-libev : Depends: libc-ares2 (>= 1.11.0~rc1) but 1.10.0-2+deb8u2 is to be installed Depends: libsodium18 (>= 1.0.12) but 1.0.11-1~bpo8+1 is to be installed E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a s olution). 升级libsodium的时候提示这个。
    bugme6年前(2018-01-18)回复
  15. You might want to run 'apt-get -f install' to correct these: The following packages have unmet dependencies: shadowsocks-libev : Depends: libc-ares2 (>= 1.11.0~rc1) but 1.10.0-2+deb8u2 is to be installed Depends: libsodium18 (>= 1.0.12) but 1.0.11-1~bpo8+1 is to be installed E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution). [Error] Failed to install gettext 大佬你好,gcp的debian 9,我自己编译的时候也是这个错误,看样子是libsodium版本过低,编译安装过libsodium,一直升级不了
    bugme6年前(2018-01-18)回复