15

ubuntu 16.04 下 shadowsocks 配置,安装与自动启动

 2 years ago
source link: https://idealclover.top/archives/339/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

ubuntu 16.04 下 shadowsocks 配置,安装与自动启动

2018.06.03 | Linux 使用 | 12282 浏览 | 6 赞 | 1 条评论


请注意,本文编写于 1267 天前,最后修改于 931 天前,其中某些信息可能已经过时。

shadowsocks 作为一款易用,简便的工具,在 win 下几乎是一键安装,还可以自由切换 PAC 模式和全局模式;而在 linux 下自己则犯了难,查阅了相关资料,最后装好了 shadowsocks。

shadowsocks-qt5(图形界面)

  1. 添加 ppa 源:
sudo add-apt-repository ppa:hzwhuang/ss-qt5
apache
  1. 更新软件列表
sudo apt-get update
csharp
  1. 安装 shadowsocks-qt5
sudo apt-get install shadowsocks-qt5
apache
  1. 配置 shadowsocks-qt5
配置项解释配置名称连接的名称服务器地址 aowsocks 服务器的 IP 地址或者域名服务器端口 Shadowsocks 服务器的端口密钥 Shadowsocks 的加密密钥本地地址本地代理服务器监听 IP 地址本地端口本地代理服务器监听端口本地服务器类型本地代理服务器的类型加密方式 Shadowsocks 的加密方式超时 TCP 连接的最长空闲时间(秒)重置数据流量流量统计中本期的最后一天,超过该天后,本期流量将被重置清零自动化程序启动时自动连接(Shadowsocks-Qt5 启动时自动激活该「连接」)
  1. 勾选程序启动时自动连接 start on login

shadowsocks(命令行界面)

  1. 安装 shadowsocks
apt-get install python-pip pip install shadowsocks
  1. 配置 shadowsocks

创建一个 json 文件,用来作为 shadowsocks 的设置,比如

sudo vim /etc/shadowsocks.json
nginx
"server":"服务器的ip", "server_port":服务器的端口, "local_address":"127.0.0.1", "local_port":1080, "password":"密码", "timeout":300, "method":"aes-256-cfb", "fast_open":false
  1. 启动与开机自启动
sslocal -c /{路径}/shadowsocks.json
properties

开机自启动则需要编写脚本。最开始使用的是 service 方式,后来没有成功,经实验编写 shell 脚本是可行的操作。需要创建一个 shell 脚本(最好是在 /usr/bin 下,命名为比如 shadowsocks.sh

sslocal -c /{路径}/shadowsocks.json
properties

给脚本赋予权限

sudo chmod +x /usr/bin/shadowsocks.sh
nginx

/etc/rc.local 中加入该脚本的完整目录

#!/bin/bash /usr/bin/shadowsocks.sh

2018.07.14 update: 增加 shadowsocks-libev 设置方法

shadowsocks-libev

shadowsocks-libev 安装

sudo apt install shadowsocks-libev
nginx

设置配置文件

配置文件目录在 /etc/shadowsocks-libev/config.json

sudo cp /etc/shadowsocks-libev/config.json /etc/shadowsocks-libev/config.json.bak

然后开始编辑该文件,配置方法同上面的 shadowsocks.json

打开客户端服务并开启开机自启

sudo systemctl start shadowsocks-libev-local@config sudo systemctl enable shadowsocks-libev-local@config

关停 shadowsocks-libev 的服务端服务

sudo systemctl stop shadowsocks-libev sudo systemctl disable shadowsocks-libev
properties

检查客户端状态

sudo systemctl status shadowsocks-libev-local@config

pac 生成与设置

  1. 安装 pip 与 genpac
apt-get install python-pip sudo pip install genpac
  1. 生成 pac 文件
genpac -p "SOCKS5 127.0.0.1:1080" --gfwlist-proxy="SOCKS5 127.0.0.1:1080" --output="~/autoproxy.pac"
nginx

这样会绝对路径 /home/{用户名} 文件夹下生成名为 autoproxy.pac 的 pac 文件,记住这个绝对路径。

  1. 设置网络代理

打开 ubuntu 的 设置 - 网络 - 网络代理 (settings - Network - Network proxy),选择方法为自动 (Automatic),URL 为 file:///{pac文件路径}

Ubuntu16.04 安装 shadowsocks-qt5 和配置
https://blog.csdn.net/weixin_36185028/article/details/79550138

Ubuntu 16 安装 shadowsocks-qt5 并使用 PAC 全局代理
https://www.litcc.com/2016/12/29/Ubuntu16-shadowsocks-pac/

Linux 安装配置 Shadowsocks 客户端及开机自动启动
https://blog.huihut.com/2017/08/25/LinuxInstallConfigShadowsocksClient/

Why do you need to put #!/bin/bash at the beginning of a script file?
https://stackoverflow.com/questions/8967902/why-do-you-need-to-put-bin-bash-at-the-beginning-of-a-script-file

本文链接:https://idealclover.top/archives/339/

本作品由 idealclover 采用 知识共享署名 - 非商业性使用 - 相同方式共享 4.0 国际许可协议 进行许可,转载请注明出处。

标签: 设置 , 服务器 , usr, 域名 , 文件 , pac, install, shadowsocks


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK