ubuntu 16.04 下 shadowsocks 配置,安装与自动启动
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.
ubuntu 16.04 下 shadowsocks 配置,安装与自动启动
2018.06.03 | Linux 使用 | 12282 浏览 | 6 赞 | 1 条评论
请注意,本文编写于 1267 天前,最后修改于 931 天前,其中某些信息可能已经过时。
shadowsocks 作为一款易用,简便的工具,在 win 下几乎是一键安装,还可以自由切换 PAC 模式和全局模式;而在 linux 下自己则犯了难,查阅了相关资料,最后装好了 shadowsocks。
shadowsocks-qt5(图形界面)
- 添加 ppa 源:
sudo add-apt-repository ppa:hzwhuang/ss-qt5
- 更新软件列表
sudo apt-get update
- 安装 shadowsocks-qt5
sudo apt-get install shadowsocks-qt5
- 配置 shadowsocks-qt5
- 勾选程序启动时自动连接 start on login
shadowsocks(命令行界面)
- 安装 shadowsocks
apt-get install python-pip
pip install shadowsocks
- 配置 shadowsocks
创建一个 json 文件,用来作为 shadowsocks 的设置,比如
sudo vim /etc/shadowsocks.json
"server":"服务器的ip",
"server_port":服务器的端口,
"local_address":"127.0.0.1",
"local_port":1080,
"password":"密码",
"timeout":300,
"method":"aes-256-cfb",
"fast_open":false
- 启动与开机自启动
sslocal -c /{路径}/shadowsocks.json
开机自启动则需要编写脚本。最开始使用的是 service 方式,后来没有成功,经实验编写 shell 脚本是可行的操作。需要创建一个 shell 脚本(最好是在 /usr/bin
下,命名为比如 shadowsocks.sh
)
sslocal -c /{路径}/shadowsocks.json
给脚本赋予权限
sudo chmod +x /usr/bin/shadowsocks.sh
在 /etc/rc.local
中加入该脚本的完整目录
#!/bin/bash
/usr/bin/shadowsocks.sh
2018.07.14 update: 增加 shadowsocks-libev 设置方法
shadowsocks-libev
shadowsocks-libev 安装
sudo apt install shadowsocks-libev
设置配置文件
配置文件目录在 /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
检查客户端状态
sudo systemctl status shadowsocks-libev-local@config
pac 生成与设置
- 安装 pip 与 genpac
apt-get install python-pip
sudo pip install genpac
- 生成 pac 文件
genpac -p "SOCKS5 127.0.0.1:1080" --gfwlist-proxy="SOCKS5 127.0.0.1:1080" --output="~/autoproxy.pac"
这样会绝对路径 /home/{用户名}
文件夹下生成名为 autoproxy.pac
的 pac 文件,记住这个绝对路径。
- 设置网络代理
打开 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 国际许可协议 进行许可,转载请注明出处。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK