OwlFocus

CentOS命令行使用shadowsocks代理的方法

CentOS命令行使用shadowsocks代理的方法

安装ShadowSocks

1
2
3
4
5
yum -y install python-setuptools
easy_install pip
pip install shadowsocks

创建配置文件/etc/shadowsocks.json

1
vim /etc/shadowsocks.json
1
2
3
4
5
6
7
8
9
{
"server":"127.0.0.1",
"server_port":8838,
"local_address": "127.0.0.1",
"local_port":1080,
"password":"password12345",
"timeout":600,
"method":"rc4-md5"
}

说明

备注:加密方式官方默认使用aes-256-cfb,推荐使用rc4-md5,因为 RC4比AES速度快。
字段说明:

1
2
3
4
5
6
server:服务器IP
server_port:服务器端口
local_port:本地端端口
password:用来加密的密码
timeout:超时时间(秒)
method:加密方法,可选择 “bf-cfb”, “aes-256-cfb”, “des-cfb”, “rc4″等

运行

1
nohup sslocal -c /etc/shadowsocks.json /dev/null 2>&1 &

安装Privoxy

下载安装包 privoxy-3.0.24-stable-src.tar.gz

1
2
3
4
5
autoheader && autoconf
./configure
make && make install

修改配置文件并启动服务

1
vim /usr/local/etc/privoxy/config

添加 listen-address

1
listen-address 127.0.0.1:8118

添加forward-socks5t

1
forward-socks5t / 127.0.0.1:1080 .

启动

1
privoxy --user privoxy /usr/local/etc/privoxy/config

或者

1
sudo service privoxy start

配置/etc/profile

1
vim /etc/profile

添加代理

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

验证

执行curl命令验证是否成功

1
2
curl www.google.com
wget www.google.com