technology:linux:ssr

# 访问https://github.com/the0demiurge/CharlesScripts/blob/master/charles/bin/ssr获取本脚本的最新版
# 使用方法:把该脚本放到$PATH里面并加入可执行权限就行(比如说放到/usr/local/bin)
# 首次使用输入ssr install后安装时会自动安装到 $HOME/.local/share/shadowsocksr
# 输入ssr config进行配置,输入JSON格式的配置文件
# 输入ssr uninstall卸载
# 输入ssr help 展示帮助信息
 
$ wget https://raw.githubusercontent.com/the0demiurge/CharlesScripts/master/charles/bin/ssr
$ chmod +x ./ssr
$ sudo mv ./ssr /usr/local/bin/
$ ssr install
$ ssr config
$ ssr start

1.安装 ssr

$ sudo apt install shadowsocks

2.创建配置文件


$ mkdir shadowsocks && cd shadowsocks/

$ vim shadowsocks.json

{
    "server":"代理地址",
    "server_port":代理端口,
    "local_address":"127.0.0.1",
    "local_port":1080,
    "password":"密码",
    "timeout":600,
    "method":"加密方式"
}

3.启动 ssr


$ sslocal -c $HOME/shadowsocks/shadowsocks.json

如果要使用 salsa20 或 chacha20 或 chacha20-ietf 算法,请安装 libsodium :


# 1.安装依赖
# Debian 7/8、Ubuntu 14/15/16 及其衍生系列:
$ sudo apt-get update
$ sudo apt-get install build-essential wget -y

# Centos 6/7、RHEL 7 及其衍生系列:
$ yum groupinstall "Development Tools" -y
$ yum install wget -y


# 2.下载 libsodium 最新版本
# 可以从libsodium 官网下,也可以从github 下载。选择速度最快的下载方式。
# 从官网下载:
$ wget https://download.libsodium.org/libsodium/releases/LATEST.tar.gz
# 从 github 下载(其中 1.0.10 是 libusodium 的版本号,可以改成最新的):
$ wget https://github.com/jedisct1/libsodium/releases/download/1.0.10/libsodium-1.0.10.tar.gz

# 3.解压
# 官网下载的:
$ tar xzvf LATEST.tar.gz
# github 下载的:
$ tar xzvf libsodium-1.0.10.tar.gz

# 4.生成配置文件
$ cd libsodium*
$ ./configure

# 5. 编译并安装
$ make -j8 && make install

# 6.添加运行库位置并加载运行库:
$ echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf
$ ldconfig


Others..

# Centos下安装:
#因为这库是基于C语言的,所以我们先去安装GCC
$ yum -y groupinstall "Development Tools"
#下载最新稳定版本
$ wget https://download.libsodium.org/libsodium/releases/LATEST.tar.gz
#解压
$ tar xf LATEST.tar.gz && cd libsodium-1.0.11
#编译
$ ./configure && make -j4 && make install
$ echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf
$ ldconfig

# ubuntu/debian下安装:
$ apt-get install build-essential
$ wget https://download.libsodium.org/libsodium/releases/LATEST.tar.gz
$ tar xf libsodium-1.0.10.tar.gz && cd libsodium-1.0.10
$ ./configure && make -j4 && make install
$ ldconfig

# 自行编译
$ yum -y groupinstall "Development Tools"
$ wget https://github.com/jedisct1/libsodium/releases/download/1.0.15/libsodium-1.0.15.tar.gz
$ tar xf libsodium-1.0.15.tar.gz && cd libsodium-1.0.15
$ ./configure && make -j2 && make install
$ echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf
$ ldconfig

# CentOS 7.4
$ yum install -y epel-release
$ yum install -y privoxy

# Ubuntu 16.04
$ apt install -y privoxy

代理模式同其他平台上方式,将所有http/https请求走代理服务,如果需要全局代理的话按照如下操作即可,如果要使用PAC模式,请跳过此部分。

# 添加本地ssr服务到配置文件
echo 'forward-socks5 / 127.0.0.1:1080 .' >> /etc/privoxy/config

# Privoxy 默认监听端口是是8118
export http_proxy=http://127.0.0.1:8118
export https_proxy=http://127.0.0.1:8118
export no_proxy=localhost

# 启动服务
systemctl start privoxy.service

这样设置完成后,只会在当前bash实例中起作用,如果想在每个实例起作用可以这样: 首先 vim /etc/profile 然后在末尾加上

export http_proxy=http://127.0.0.1:8118
export https_proxy=http://127.0.0.1:8118
export http_proxy https_proxy

保存后再

source /etc/profile

使用GFWList是由AutoProxy官方维护,由众多网民收集整理的一个中国大陆防火长城的屏蔽列表,这里感谢@Otokaze 为我们提供了转换shell自动转换脚本,为了方便修改,我fork了这个项目,将这篇教程所用到的资源进行了汇总,你可以在最开始git clone的目录中找到执行脚本。

[root@localhost ~]# cd gfwlist2privoxy/
[root@localhost gfwlist2privoxy]# ls
gfw.action  gfwlist2privoxy  README.md  ssr
[root@localhost gfwlist2privoxy]# bash gfwlist2privoxy
proxy(socks5): 127.0.0.1:1080		# 注意,如果你修改了ssr本地监听端口是需要设置对应的
{+forward-override{forward-socks5 127.0.0.1:1080 .}}

=================================================================

"cp -af /root/gfwlist2privoxy/gfw.action /etc/privoxy/"

[root@localhost ~]# cp -af gfw.action /etc/privoxy/
[root@localhost ~]# echo 'actionsfile gfw.action' >> /etc/privoxy/config

# Privoxy 默认监听端口是是8118
export http_proxy=http://127.0.0.1:8118
export https_proxy=http://127.0.0.1:8118
export no_proxy=localhost

# 启动服务
systemctl start privoxy.service
# privoxy默认监听端口为8118
export http_proxy=http://127.0.0.1:8118
export https_proxy=http://127.0.0.1:8118
export no_proxy=localhost

# no_proxy是不经过privoxy代理的地址
# 只能填写具体的ip、域名后缀,多个条目之间使用','逗号隔开
# 比如: export no_proxy="localhost, 192.168.1.1, ip.cn, chinaz.com"
# 访问 localhost、192.168.1.1、ip.cn、*.ip.cn、chinaz.com、*.chinaz.com 将不使用代理
#!/bin/bash
# 作者:老徐
# SSR免费分享网站(所有帐号均来源于网上别人的分享):http://ss.pythonic.life
# 源代码主页:https://github.com/the0demiurge
# 访问https://github.com/the0demiurge/CharlesScripts/blob/master/charles/bin/ssr获取本脚本的最新版
#使用方法:把该脚本放到$PATH里面并加入可执行权限就行(比如说放到/usr/local/bin)
#首次使用输入ssr install后安装时会自动安装到/usr/local/share/shadowsocksr
#输入ssr config进行配置,输入JSON格式的配置文件
#输入ssr uninstall卸载
#输入ssr help 现实帮助信息
set -e
if [ -z $EDITOR ];then
    EDITOR=vi
fi

help() {
    echo ShadowSocksR python client tool
    echo -e if you have not install ssr, please run \"ssr install\"
    echo Usage:
    echo -e "\t" ssr help
    echo -e "\t" ssr config : edit config.json
    echo -e "\t" ssr install : install shadowsocksr client
    echo -e "\t" ssr uninstall : uninstall shadowsocksr client
    echo -e "\t" ssr start : start the shadowsocks service
    echo -e "\t" ssr stop : stop the shadowsocks service
    echo -e "\t" ssr log : cat the log of shadowsocks
}
install_path=/usr/local/share/shadowsocksr
if [ $# == 0 ];then
    help
    
elif [ $1 == "help" ];then
    help
    
elif [ $1 == "install" ];then
    sudo git clone -b manyuser https://github.com/shadowsocksr-backup/shadowsocksr.git $install_path
    # sudo git clone -b rm https://github.com/the0demiurge/not-in-use.git $install_path
    
elif [ $1 == "uninstall" ];then
    echo "Danger! are you to remove $install_path forever?(y/N)"
    read doit
    if [ $doit == 'y' ];then
        sudo rm -rvf $install_path
    fi
    
elif [ $1 == "config" ];then
    sudo $EDITOR $install_path/config.json
    cd $install_path/shadowsocks/
    sudo python local.py -d stop
    sudo python local.py -d start
    
elif [ $1 == "start" ];then
    cd $install_path/shadowsocks/
    sudo python local.py -d start
    
elif [ $1 == "stop" ];then
    cd $install_path/shadowsocks/
    sudo python local.py -d stop
    
elif [ $1 == "log" ];then
    tail -f /var/log/shadowsocks.log
    
elif [ $1 == "shell" ];then
    cd $install_path/shadowsocks/
    sudo python local.py $@
fi
  • technology/linux/ssr.txt
  • 最后更改: 2019/11/29 09:16
  • (外部编辑)