一、安装SS(需要本机可以翻墙)
直接使用默认源安装的SS是一个极老的版本(2.1.0),因此我们不能使用如下命令直接安装。
1 |
apt-get install shadowsocks |
虽然github仓库中的很多内容已经被移除,但是我们依然可以从release中下载到比2.1.0更新的源码,如图:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
root@mid003:~# wget https://github.com/shadowsocks/shadowsocks/archive/2.9.1.tar.gz root@mid003:~# mv 2.9.1.tar.gz ss-2.9.1.tar.gz root@mid003:~# tar zvxf ss-2.9.1.tar.gz root@mid003:~/shadowsocks-2.9.1# python setup.py install root@mid003:~/shadowsocks-2.9.1# sslocal ERROR: config not specified usage: sslocal [OPTION]... A fast tunnel proxy that helps you bypass firewalls. You can supply configurations via either config file or command line arguments. Proxy options: -c CONFIG path to config file -s SERVER_ADDR server address -p SERVER_PORT server port, default: 8388 -b LOCAL_ADDR local binding address, default: 127.0.0.1 -l LOCAL_PORT local port, default: 1080 -k PASSWORD password -m METHOD encryption method, default: aes-256-cfb -t TIMEOUT timeout in seconds, default: 300 -a ONE_TIME_AUTH one time auth --fast-open use TCP_FASTOPEN, requires Linux 3.7+ General options: -h, --help show this help message and exit -d start/stop/restart daemon mode --pid-file PID_FILE pid file for daemon mode --log-file LOG_FILE log file for daemon mode --user USER username to run as -v, -vv verbose mode -q, -qq quiet mode, only show warnings/errors --version show version information Online help: <https://github.com/shadowsocks/shadowsocks> root@mid003:~/shadowsocks-2.9.1# |
创建SS的配置文件,随便找个地方放即可,例如放在/root/shadowsocks下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
root@mid003:~/ss# pwd /root/ss root@mid003:~/ss# cat ss.json { "server": "47.*.*.*", "server_port": 443, "password": "password", "method": "aes-256-cfb", "plugin": "", "plugin_opts": "", "plugin_args": "", "remarks": "", "timeout": 5 } root@mid003:~/ss# |
使用如下命令启动SS进行测试:
1 2 3 4 5 6 7 |
root@mid003:~/ss# sslocal -c /root/ss/ss.json INFO: loading config from /root/ss/ss.json 2019-11-06 22:31:46 WARNING warning: your timeout 5 seems too short 2019-11-06 22:31:46 INFO loading libcrypto from libcrypto.so.1.0.0 2019-11-06 22:31:46 INFO starting local at 127.0.0.1:1080 2019-11-06 22:32:49 INFO connecting www.google.com:443 from 127.0.0.1:48976 ^Croot@mid003:~/ss# |
如果是要后台运行的话可以:
1 |
sslocal -c /root/ss/ss.json -d start |
二、安装全局代理工具privoxy
SS的1080暴露的是SOCKS5接口,需要使用全局代理工具转发其他请求。
1 |
apt-get install privoxy |
修改配置文件privoxy的配置文件/etc/privoxy/config,保证其中生效两行:
1 2 |
listen-address localhost:8118 forward-socks5t / 127.0.0.1:1080 . |
使用如下命令启停privoxy:
1 2 |
sudo privoxy --user privoxy /etc/privoxy/config systemctl stop privoxy |
为终端配置http代理:
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 |
三、测试是否生效
1 |
curl -v www.google.com |
转载时请保留出处,违法转载追究到底:进城务工人员小梅 » Ubuntu 16.04.6 LTS下SS全局代理