Shadowsocks Python版一键安装脚本

技术 秋水逸冰 2388449浏览 1333评论

本脚本适用环境:
系统支持:CentOS 6,7,Debian,Ubuntu
内存要求:≥128M
日期:2018 年 02 月 07 日

关于本脚本:
一键安装 Python 版 Shadowsocks 的最新版。
友情提示:如果你有问题,请先参考这篇《Shadowsocks Troubleshooting》后再问。

默认配置:
服务器端口:自己设定(如不设定,默认从 9000-19999 之间随机生成)
密码:自己设定(如不设定,默认为 teddysun.com)
加密方式:自己设定(如不设定,默认为 aes-256-gcm)
备注:脚本默认创建单用户配置文件,如需配置多用户,安装完毕后参照下面的教程示例手动修改配置文件后重启即可。

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

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

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

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

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!

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

./shadowsocks.sh uninstall

单用户配置文件示例(2015 年 08 月 28 日修正):
配置文件路径:/etc/shadowsocks.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
}

多用户多端口配置文件示例(2015 年 08 月 28 日修正):
配置文件路径:/etc/shadowsocks.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
}

使用命令(2015 年 08 月 28 日修正):
启动:/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)
CentOS 下 Shadowsocks-libev 一键安装脚本
Debian 下 Shadowsocks-libev 一键安装脚本
Shadowsocks-go 一键安装脚本(CentOS,Debian,Ubuntu)
Shadowsocks 一键安装脚本(四合一)

参考链接:
https://teddysun.com/339.html

更新日志

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

(2017 年 07 月 21 日)
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

(2016 年 08 月 18 日)
1、修正:默认安装 Github 上 master 分支最新版本(目前为 2.9.0)。
2、修正:由于原作者已经不再更新 pip 下的源代码,故不再使用 pip 安装 Shadowsocks,而是改为下载 Github 的 master 分支来安装。如果在一段时间后,版本升级了,则先卸载,并再次执行本脚本就可以升级为最新版。

(2016 年 05 月 12 日)
1、新增在 CentOS 7 下的防火墙规则设置。

(2015 年 08 月 28 日)
1、修正控制脚本 /etc/init.d/shadowsocks 在 CentOS 7 无法查看 status 的问题。

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

(2015 年 03 月 10 日)
1、新增在 Debian、Ubuntu 下的一键安装;

(2015 年 01 月 21 日)
1、修正配置文件,与官方给出的 Sample 一致;
2、修改启动脚本,使用官方给出的后台启动和停止命令。

(2014 年 10 月 10 日)
跟作者反馈了多用户多端口问题,作者已更新 Wiki 页面。本教程新增多用户多端口配置文件的 sample 。

(2014 年 09 月 24 日)
如何配置多用户?详见:这里
备注:Shadowsocks 已经支持多用户,在配置文件中增加不同的端口,对应不同的密码即可。

(2014 年 07 月 12 日)
1、修正获取公网 IP 时的一个问题。建议不要使用共享公网 IP 的 VPS 来搭建 Shadowsocks 服务。

(2014 年 05 月 29 日)
1、增加 chkconfig 配置,实现 service 命令。
2、配置文件名从 /etc/config.json 改为 /etc/shadowsocks.json(与官方的命名一致)。
3、配置文件中新增 workers ,值默认为 1(与官方配置同步)。

(2014 年 05 月 27 日)
1、修正开机自启动失效的问题。
2、优化是否后台启动成功的判断逻辑。

(2014 年 05 月 04 日)
1、修正对增加防火墙端口逻辑的判断bug,对于已经放行 8989 端口的情况下,则无需再次增加。
2、修正获取服务器 IP 的判断bug,对于多 IP 的 VPS 或服务器,默认只取第一个公网 IP 写到配置文件(/etc/config.json)里。
3、加入开机自启动。

转载请注明:秋水逸冰 » Shadowsocks Python版一键安装脚本

发表我的评论
取消评论

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

表情

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

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

网友最新评论 (1333)

  1. 看着配置也不是很难...
    灰常记忆8年前(2016-09-23)回复
  2. 举手提问:shadowsock原作者被请去喝茶了 2.5.7之后的版本来自不同作者 可靠性是否有保障?
    Zzzzz8年前(2016-09-20)回复
  3. 你好博主,python版配置文件如何启用ipv6支持?
    ad8年前(2016-09-18)回复
  4. 不知道为什么,设置多用户配置文件后,还是只能用安装时的用户名和密码,我试过更新配置文件后重启SS服务器,重启VPS,都不行,下面是我的配置文件,只能用443那个用户了 { "server":"0.0.0.0", "local_address":"127.0.0.1", "local_port":1080, "port_password":{ "2016":"2016", "443":"443", "12345":"12345" }, "timeout":300, "method":"aes-256-cfb", "fast_open": false }
    Killerm8年前(2016-09-18)回复
    • 我想应该是防火墙的问题。iptables 或者 firewalld 里对其他的端口放行。
      秋水逸冰8年前(2016-09-19)回复
  5. 把libsodium-1.0.11.tar.gz和shadowsocks-master.zip自己放入vps的/root里。通过第一条命令下载shadowsocks.sh到vps,手动删除脚本中关于下载libsodium-1.0.11.tar.gz和shadowsocks-master.zip的字段。在运行博主给的第二段和第三段命令。 可以搞定alpharacks目前的问题,改服务商可以换啦。小白两天来的代价。
    Tesla8年前(2016-09-13)回复
    • Good!自己动手,丰衣足食。
      秋水逸冰8年前(2016-09-13)回复
      • 我删除了字段还是没有通过 提示gzip: stdin: unexpected end of file tar: Child returned status 1 tar: Error is not recoverable: exiting now ./shadowsocks.sh: line 263: cd: libsodium-1.0.11/: No such file or directory ./shadowsocks.sh: line 264: ./configure: No such file or directory libsodium install failed! [root@wyangege ~]#
        jack8年前(2016-09-14)回复
    • 楼主加我qq282880331,我想问个问题
      jack8年前(2016-09-14)回复
    • 能把你删掉libsodium-1.0.11.tar.gz和shadowsocks-master.zip的字段的shadowsocks.sh 给我一个吗?谢谢了 [email protected]
      jack8年前(2016-09-14)回复
      • 将第一段命令改成 wget --no-check-certificate http://netuse.16mb.com/shadowsocks.sh alpharacks的用户可以从我的虚拟主机下,我已经把master和 libsodium文件也都放我虚拟主机,命令也相应改好了。刚搞的免费虚拟主机,存活多久不知道
        Neil8年前(2016-09-15)回复
        • 谢谢!按照你的命令安装成功了!!!!
          say8年前(2016-09-18)回复
      • 删除 # Download libsodium file if ! wget --no-check-certificate -O libsodium-1.0.11.tar.gz https://github.com/jedisct1/libsodium/releases/download/1.0.11/libsodium-1.0.11.tar.gz; then echo "Failed to download libsodium-1.0.11.tar.gz!" exit 1 fi # Download Shadowsocks file if ! wget --no-check-certificate -O shadowsocks-master.zip https://github.com/shadowsocks/shadowsocks/archive/master.zip; then echo "Failed to download shadowsocks python file!" exit 1 fi
        Tesla8年前(2016-09-17)回复
  6. 问个题外话。我的vps能在下https://raw.githubusercontent.com中的文件,不能下载https://github.com里的文件。提示Connecting to github.com (github.com)|192.30.253.112|:443... failed: Connection timed out. 此题有解吗? 貌似博主提供的一键脚本都有https://github.com下的文件需要下载。
    Tesla8年前(2016-09-11)回复
    • 我也遇到同样的问题,希望大神给个方案解决。
      jack8年前(2016-09-11)回复
    • 是啊,现在安装都是报 Connecting to github.com (github.com)|192.30.253.112|:443... failed: Connection timed out,
      lionnner8年前(2016-09-12)回复
    • 同样 --2016-09-12 10:29:39-- (try: 3) https://github.com/jedisct1/libsodium/releases/download/1.0.11/libsodium-1.0.11.tar.gz Connecting to github.com (github.com)|192.30.253.112|:443... --2016-09-12 10:27:30-- https://github.com/jedisct1/libsodium/releases/download/1.0.11/libsodium-1.0.11.tar.gz Resolving github.com (github.com)... 192.30.253.112 Connecting to github.com (github.com)|192.30.253.112|:443... failed: Connection timed out. Retrying. --2016-09-12 10:28:34-- (try: 2) https://github.com/jedisct1/libsodium/releases/download/1.0.11/libsodium-1.0.11.tar.gz Connecting to github.com (github.com)|192.30.253.112|:443... failed: Connection timed out. Retrying. --2016-09-12 10:29:39-- (try: 3) https://github.com/jedisct1/libsodium/releases/download/1.0.11/libsodium-1.0.11.tar.gz Connecting to github.com (github.com)|192.30.253.112|:443... 也是alpharacks……
      shinzi8年前(2016-09-12)回复
  7. 请问一键安装的时候出现这个显示是什么问题?谢谢! --2016-09-10 21:06:14-- (try: 2) https://github.com/jedisct1/libsodium/releases/download/1.0.11/libsodium-1.0.11.tar.gz Connecting to github.com (github.com)|192.30.253.112|:443... failed: Connection timed out. Retrying.
    say8年前(2016-09-11)回复
    • 一般拿来安装 SS 的都是国外的 VPS,所以为什么连接不上 Github 应该找找 VPS 的原因吧。
      秋水逸冰8年前(2016-09-11)回复
      • 我的VPS是alpharacks。半年前安装过这个一键安装,没有问题。前天重新安装的时候出现这个问题。向alpharacks客服提出过这个问题,但没有解决。所以不知道到底是哪方面的问题导致的。谢谢
        say8年前(2016-09-12)回复
        • 好吧,看来都是 alpharacks 他家的。 他家前几天不是机房出故障了啊,应该在修复吧,我开了个ticket,显示 in progress,等吧
          lionnner8年前(2016-09-13)回复
          • 你 弄好了吗? 我的还在瘫痪,能加我qq吗?一起研究 282880331
            jack8年前(2016-09-13)回复
            • 请看前面朋友的帮助!我在他的帮助下搞好了! 将第一段命令改成 wget --no-check-certificate http://netuse.16mb.com/shadowsocks.sh
              say8年前(2016-09-18)回复
  8. 再问一下,shadowsocks.json 里面server ip 要改成自己的服务器IP嘛,还是就0.0.0.0就好了? 还有,我安装完shadowsocks,我已经设置了8989端口的密码,请问在shadowsocks.json 里面还要再设置一次嘛
    showeb8年前(2016-09-11)回复
    • 服务器 IP 按照默认设置就好了。 安装的过程中脚本会要求你设置密码,设成什么就是什么,无需再次设置。
      秋水逸冰8年前(2016-09-11)回复
  9. No connection could be made because the target machine actively refused it 在shadowsocks的log里面看到这个,连接上就没办法上网,请问怎么办。。。
    showeb8年前(2016-09-11)回复
  10. 求问大大。。不是用一键脚本安装的怎么升级shadowsocks?现在pip都不行了。。求救!!thx!!
    nick8年前(2016-09-10)回复
    • pip 本来就常年不更新了。 所以我更新了脚本,改为使用 Github 上 master 分支来安装。
      秋水逸冰8年前(2016-09-10)回复
      • 所以我想问怎么从master分支安装。。不升级到最新有什么区别?。。求解答。。thx
        nick8年前(2016-09-10)回复
  11. 骚瑞 看到脚本中已经编译了此lib库 并且安装了么么哒看来可以之间欸用chacha20了
    大官人8年前(2016-09-09)回复
  12. github.com/jedisct1/libsodium 能否支持chacha20加密?路由器表示默认加密方式速度比较慢
    大官人8年前(2016-09-09)回复
  13. 现在用github来安装,那怎么看现在机器安装的shadowsocks版本是多少?
    DearTanker8年前(2016-09-09)回复
    • 也许你需要以下命令来查看版本号: ssserver --version
      秋水逸冰8年前(2016-09-10)回复
  14. 请问如何添加ipv6的支持?如果vps既有ipv4又有ipv6的ip
    opteroncx8年前(2016-09-05)回复
  15. 秋水大,运行时报错: INFO loading libcrypto from libcrypto.so.1.0.0 ERROR already started at pid 2399 这个如何解
    Chica8年前(2016-09-03)回复
    • 你仔细看看提示语。 是已经启动了。
      秋水逸冰8年前(2016-09-03)回复
      • 是的,已经启动了,这个报错直接忽略吗?多谢回复
        Chica8年前(2016-09-05)回复