Debian下shadowsocks-libev一键安装脚本

技术 秋水逸冰 681914浏览 514评论

本脚本适用环境:
系统支持:Debian/Ubuntu
内存要求:≥128M
日期:2018 年 06 月 01 日

关于本脚本:
Debian 或 Ubuntu 下一键安装 libev 版的 Shadowsocks 最新版本。该版本的特点是内存占用小(600k左右),使用 libev 和 C 编写,低 CPU 消耗,甚至可以安装在基于 OpenWRT 的路由器上。
友情提示:如果你有问题,请先参考这篇《Shadowsocks Troubleshooting》后再问。

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

客户端下载:
https://github.com/shadowsocks/shadowsocks-windows/releases

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

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

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

Congratulations, Shadowsocks-libev 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/358.html
Enjoy it!

卸载方法:
使用 root 用户登录,运行以下命令:

./shadowsocks-libev-debian.sh uninstall

其他事项:
客户端配置的参考链接:https://teddysun.com/339.html
本脚本安装完成后,已将 Shadowsocks-libev 加入开机自启动。

使用命令:
启动:/etc/init.d/shadowsocks start
停止:/etc/init.d/shadowsocks stop
重启:/etc/init.d/shadowsocks restart
查看状态:/etc/init.d/shadowsocks status

更多版本 Shadowsocks 服务端一键安装脚本:
ShadowsocksR 版一键安装脚本(CentOS,Debian,Ubuntu)
Shadowsocks Python 版一键安装脚本(CentOS,Debian,Ubuntu)
CentOS 下 Shadowsocks-libev 一键安装脚本
Shadowsocks-go 一键安装脚本(CentOS,Debian,Ubuntu)
Shadowsocks 一键安装脚本(四合一)

更新日志

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

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

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

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

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

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

2017 年 02 月 13 日:
1、更新:升级版本到 3.0.2。
2、修复:在 Debian 7 下默认没有 libudns-dev 依赖包的问题。

2017 年 02 月 12 日:
1、更新:升级版本到 3.0.1(请下载最新的脚本来安装)。

2016 年 11 月 05 日:
1、新增:判断是否已安装,若已安装,则获取版本号与最新版比较,然后可以升级覆盖安装;
2、修正:未安装时获取最新版本号的问题。

2016 年 09 月 23 日:
1、修正:偶尔自动获取版本号失败的问题;
2、新增:自动判断如果 VPS 存在 IPv6 地址,则在配置文件里添加监听 IPv6 地址。

2016 年 09 月 17 日:
1、重构代码,自动获取 Github 上最新版来安装,不再手动修改版本号;
2、自动检测本机是否已经安装,若已安装则正常退出(若要安装新版,则需先卸载);
3、改为下载 tar.gz 包来安装,不用依赖 unzip 命令。

2016 年 09 月 12 日:
1、更新:升级版本到 2.5.2。

2016 年 09 月 11 日:
1、更新:升级版本到 2.5.1。

2016 年 08 月 29 日:
1、更新:升级版本到 2.5.0;
2、修正:由于安装时文件名的更新,卸载时文件名改为一致。

2016 年 07 月 14 日:
1、更新:升级版本到 2.4.7。

2016 年 07 月 05 日:
1、修正:新增的依赖 xmlto、asciidoc;
2、修正:由于安装时文件名的更新,卸载时文件名改为一致。

2016 年 05 月 12 日:
1、修正:Shadowsocks 服务改为强制默认开机启动。

2015 年 08 月 01 日:
1、新增:自定义服务器端口功能(如不设定,默认端口为 8989)。

2015 年 04 月 30 日:
1、修改配置文件 /etc/shadowsocks-libev/config.json 同时启用 IPv4 与 IPv6 支持:

{
    "server":["[::0]","0.0.0.0"],
    "server_port":your_server_port,
    "local_address":"127.0.0.1",
    "local_port":1080,
    "password":"your_password",
    "timeout":600,
    "method":"aes-256-cfb"
}

2、Shadowsocks libev 版不能通过修改配置文件来多端口(只能开启多进程),如果你需要多端口请安装 Python 或 Go 版;

2015 年 03 月 09 日:
1、新增:启动脚本/etc/init.d/shadowsocks,使用更简单。
2、修正:优化安装过程。

2014 年 10 月 31 日:
1、修正:写入自启动命令到 /etc/rc.local 中的错误。

特别说明:
已安装旧版本的 Shadowsocks 需要升级的话,需下载本脚本的最新版,直接运行即可自动升级

./shadowsocks-libev-debian.sh

参考链接:
https://github.com/shadowsocks/shadowsocks-libev

转载请注明:秋水逸冰 » Debian下shadowsocks-libev一键安装脚本

发表我的评论
取消评论

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

表情

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

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

网友最新评论 (514)

  1. 博主你好,我近期使用了博客提供的一键包准备部署在新 VPS 上(之前有一次顺利部署在另一 VPS(CentOS)的经历,脚本很好用 ^^),Debian 和 Ubuntu 都测试过了,发现 SS 好像不能开机自启,遂查看了一下脚本,发现启动 SS 的语句"nohup /usr/local/bin/ss-server -c /etc/shadowsocks/config.json > /dev/null 2>&1 &"被添加在"exit 0"之后了。 由于本人对语法也不是特别熟悉,不知 SS 没有开机自启是否有这个原因,冒昧打扰,希望博主见谅~
    WANG10年前(2014-08-22)回复
    • 我是添加了启动语句 nohup /usr/local/bin/ss-server -c /etc/shadowsocks/config.json > /dev/null 2>&1 & 到 /etc/rc.local 文件,默认是追加在此文件的末尾,如果原先存在 exit 0 ,那么肯定就是在最后了。 手动修改一下 /etc/rc.local 文件,将启动语句放在 exit 0 之前再试试看。
      秋水逸冰10年前(2014-08-22)回复
      • 已测试,可行。不知技术上能不能先删除句末的"exit 0",在添加自启动代码?
        WANG10年前(2014-08-22)回复
  2. 2014-08-16 23:21:12 (775 KB/s) - `shadowsocks-libev.zip' saved [1087199/1087199] ./shadowsocks-libev-debian.sh: line 92: unzip: command not found Unzip shadowsocks-libev failed! Please visit https://teddysun.com/358.html and contact. orz,我在centos和debian都失败.....博主我来contact你了,怎么回事呢?
    狂舞小薰10年前(2014-08-17)回复
    • 本文的脚本要在 Debian 下安装,至于你说的 CentOS 下安装的参考此文。出错是因为系统默认没有安装 unzip 包,Debian 下执行:apt-get install -y unzip ;CentOS 下执行:yum install -y unzip 即可。
      秋水逸冰10年前(2014-08-17)回复
  3. 楼主你好,最近服务端老是自动关闭怎么解决啊?
    ninetynine10年前(2014-08-03)回复
    • 检查一下你的 VPS 是否有大内存应用导致内存不够用被自动 Kill 了进程。 服务端只占用很少的内存,自动关闭这种事基本上不会发生。检查你的 VPS 是否被服务商给重启了?如果是重启的话,shadowsocks 在 Debian 下不会自动启动(待测试),所以需要手动启动一下。
      秋水逸冰10年前(2014-08-04)回复
  4. 谢谢lz咯。懒人飘过……
    xgfan10年前(2014-07-30)回复
  5. 安装报错,执行 ./shadowsocks-libev-debian.sh 2>&1 | tee shadowsocks-libev-debian.log 后报错: finishing deferred symbolic links: shadowsocks-libev-master/Changes -> debian/changelog checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking for style of include used by make... GNU checking for gcc... no checking for cc... no checking for cl.exe... no configure: error: in `/root/shadowsocks-libev-master': configure: error: no acceptable C compiler found in $PATH See `config.log' for more details make: *** No targets specified and no makefile found. Stop. Shadowsocks-libev install failed! Please visit https://teddysun.com/358.html and contact.
    ShunYea10年前(2014-07-28)回复
    • 应该是你的 VPS 是精简版的 Debian 系统,默认没有安装 gcc 编译器。 执行命令:apt-get install -y gcc 然后再执行本脚本应该就可以了。
      秋水逸冰10年前(2014-07-28)回复
  6. nice.很不错哦
    SHLos10年前(2014-07-18)回复
  7. 这真是极好的。。。。。。。。。谢谢
    ryan10年前(2014-07-16)回复
  8. 下次更新,能不能加上端口随机生成啊
    levi10年前(2014-07-16)回复
    • 端口号只要是在 1000 到 65535 之间就可以,你也可以自己改端口号,然后防火墙放行即可。设一个固定的端口,是我的习惯问题。我怕随机生成的端口会和现有的端口重复从而产生冲突,所以就没这么干。
      秋水逸冰10年前(2014-07-16)回复
  9. 楼主debian下的shadowsocks-libev转贴了,一键包不折腾,哈哈。谢谢!
    wanjie10年前(2014-07-09)回复
  10. 好无语,还非得让我打中文 2014-07-07 03:17:00 INFO: initialize ciphers... aes-256-cfb 2014-07-07 03:17:00 ERROR: bind: Cannot assign requested address 2014-07-07 03:17:00 ERROR: Could not bind 2014-07-07 03:17:00 ERROR: bind() error..
    幽灵10年前(2014-07-07)回复
    • 评论必须有中文是为了防止 spam 的,关于你的错误提示,去 Github 上问作者比较靠谱,我只是一键安装脚本而已。
      秋水逸冰10年前(2014-07-07)回复
  11. Resolving raw.githubusercontent.com... 199.27.77.133 Connecting to raw.githubusercontent.com|199.27.77.133|:443... connected. WARNING: certificate common name `www.github.com' doesn't match requested host name `raw.githubusercontent.com'. HTTP request sent, awaiting response... 200 OK Length: 6632 (6.5K) [text/plain] Saving to: `shadowsocks-libev-debian.sh' 0K ...... 100% 79.2M=0s 2014-06-29 16:30:32 (79.2 MB/s) - `shadowsocks-libev-debian.sh' saved [6632/6632] --2014-06-29 16:30:32-- http://chmod/ Resolving chmod... failed: Name or service not known. wget: unable to resolve host address `chmod' --2014-06-29 16:30:32-- http://+x/ Resolving +x... failed: Name or service not known. wget: unable to resolve host address `+x' --2014-06-29 16:30:32-- http://shadowsocks-libev-debian.sh/ Resolving shadowsocks-libev-debian.sh... failed: Name or service not known. wget: unable to resolve host address `shadowsocks-libev-debian.sh' --2014-06-29 16:30:32-- http://./shadowsocks-libev-debian.sh Resolving .... failed: No address associated with hostname. wget: unable to resolve host address `.' FINISHED --2014-06-29 16:30:32-- Downloaded: 1 files, 6.5K in 0s (79.2 MB/s) Exit code: 0 [root /]# 求教?》求教?》求教?》
    求教?》10年前(2014-06-30)回复
    • 要不就是你的 VPS 的 DNS 设置问题,要不就是网络的问题,根本没有将 github 上作者的安装包下载回来,所以才会出错。请先确认你的 VPS 能连上外网。
      秋水逸冰10年前(2014-06-30)回复
  12. 原来config.json 里面是内网IP 192.168.211.10 我换成了外网IP 怎么就启动不 了呢
    幽灵10年前(2014-06-27)回复
    • 在 Debian 里用自带的 vim 来改配置文件,确保配置文件是对的并且编码是 unix 的(不要下载到 Windows 里修改再上传)。执行以下命令启动: nohup /usr/local/bin/ss-server -c /etc/shadowsocks/config.json > /dev/null 2>&1 &
      秋水逸冰10年前(2014-06-27)回复
  13. 密码怎么改?
    密码怎么改10年前(2014-06-26)回复
    • 修改配置文件 /etc/shadowsocks/config.json 中的 password 的值后重启即可。
      秋水逸冰10年前(2014-06-26)回复
  14. 我在Lowendsprirt的低价VPS上(NAt ipv4)安装SS,但是打开网页总是显示重置,不知道是否是因为配置文件IP及端口的问题,请站长帮忙
    cinmo10年前(2014-06-23)回复
  15. 感谢分享
    徐子子子子10年前(2014-06-16)回复