Linux安装ss客户端

2.4k words

安装ss

1
2
yum install python-pip
pip install shadowsocks

创建配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
vi /etc/shadowsocks.json

#在文件中添加一下内容:
{
"server":["101.101.101.101"],
"server_port":6666,
"password":"xxxxxxxx",
"timeout":300,
"method":"aes-256-cfb",
"local_address":"127.0.0.1",
"local_port":1080,
"fast_open":false,
"tunnel_remote":"8.8.8.8",
"dns_server":["8.8.8.8", "8.8.4.4"],
"tunnel_remote_port":53,
"tunnel_port":53
}
  • server : 服务器地址
  • server_port:服务器端口号
  • password:密码
  • method:加密方式

启动ss

1
sslocal -c /etc/shadowsocks.json
  1. 错误:ERROR method aes-256-gcm not supported

    ss版本太低,可以用sslocal --version,一般都是2.8.2,需要升级到3.0

    1
    2
    3
    4
    5
    git clone https://github.com/shadowsocks/shadowsocks.git master
    cd master
    git checkout master
    python setup.py install
    sslocal --version

    也可以直接使用pip进行安装:

    1
    pip install https://github.com/shadowsocks/shadowsocks/archive/master.zip -U
  2. 错误:libsodium not found,需要手动编译 libsodium 1.0.8 及以上版本

    • Debian 7/8、Ubuntu 14/15/16 及其衍生系列:
    1
    2
    sudo apt-get update
    sudo apt-get install build-essential wget -y
    • Centos 6/7、RHEL 7 及其衍生系列:
    1
    2
    yum groupinstall "Development Tools" -y
    yum install wget -y

    安装libsodium:

    1
    2
    3
    4
    5
    wget https://download.libsodium.org/libsodium/releases/LATEST.tar.gz
    tar xzvf LATEST.tar.gz
    cd libsodium*
    ./configure --prefix=/usr/local/libsodium
    make && make install

    添加运行库位置并加载运行库:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    #编辑文件
    vim /etc/ld.so.conf

    #输入以下内容
    include ld.so.conf.d/*.conf"
    /lib
    /usr/lib64
    /usr/local/lib
    /usr/local/libsodium/lib

    #使配置生效
    ldconfig

配置服务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#编辑文件
vi /etc/systemd/system/shadowsocks.service

#输入以下内容
[Unit]
Description=Shadowsocks
[Service]
TimeoutStartSec=0
ExecStart=sslocal -c /etc/shadowsocks.json
[Install]
WantedBy=multi-user.target

#启动
systemctl enable shadowsocks.service
systemctl start shadowsocks.service
systemctl status shadowsocks

检查服务是否运行正常:

1
curl --socks5 127.0.0.1:1080 http://httpbin.org/ip

使用ss代理

安装privoxy

privoxy可以将ss提供的socket5代理转为http代理

1
2
3
4
5
6
7
8
9
10
11
12
13
#安装
yum install privoxy

#配置
vi /etc/privoxy/config
#确保文件中有以下两行
listen-address 127.0.0.1:8118
forward-socks5t / 127.0.0.1:1080 .

#启动服务
systemctl enable privoxy
systemctl start privoxy
systemctl status privoxy

使用

临时启动http代理:

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

测试:

1
curl www.google.com

永久启用http代理:

1
2
3
4
5
6
7
8
9
#编辑配置文件
vi /etc/profile

#配置
export http_proxy=http://127.0.0.1:8118
export https_proxy=http://127.0.0.1:8118

#生效
source /etc/profile
Comments