注:以下所有操作均在CentOS 6.8 x86_64位系统下完成。
#准备工作#
在这之前推荐先将python升级到2.7,详见:CentOS安装python-2.7+安装pip-10.0.0。
#安装***#
***安装时是不分客户端还是服务器端的,只不过安装后有两个脚本,一个是sslocal代表以客户端模式工作,一个是ssserver代表以服务器端模式工作。
# yum install python-pip # pip install s Looking in indexes: http://mirrors.aliyun.com/pypi/simple/ Collecting s Downloading http://mirrors.aliyun.com/pypi/packages/02/1e/e3a5135255d06813aca6631da31768d44f63692480af3a1621818008eb4a/s-2.8.2.tar.gz Installing collected packages: s Running setup.py install for s ... done Successfully installed s-2.8.2 # which sslocal /usr/local/python-2.7/bin/ssserver
# which sslocal
/usr/local/python-2.7/bin/ssserver
然后给***创建一个配置文件:
# mkdir -p /data/s # vim /data/s/config.json { "server":"your_server_ip", # SS服务器IP "server_port":your_server_port, # 端口 "local_address": "127.0.0.1", # 本地ip "local_port":1080, # 本地端口 "password":"your_server_passwd",# 连接ss密码 "timeout":180, # 等待超时 "method":"aes-256-cfb", # 加密方式 "fast_open": false, # true 或 false。如果你的服务器 Linux 内核在3.7+,可以开启 fast_open 以降低延迟。开启方法: echo 3 > /proc/sys/net/ipv4/tcp_fastopen 开启之后,将 fast_open 的配置设置为 true 即可 "workers": 1 # 工作线程数 }
这个时候可以通过以下命令进行开启客户端:
# sslocal -c /data/s/config.json -d start INFO: loading config from /data/s/config.json 2018-04-20 08:43:03 INFO loading libcrypto from libcrypto.so.10 started
# netstat -an
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:1080 0.0.0.0:* LISTEN
可以看到sslocal正在使用1080端口,至此,***安装完毕。
#安装Privoxy#
虽然已经安装好了***,但它只是socks5代理,我们在SSH里执行的命令只支持HTTP/HTTPS代理,所以我们需要安装Privoxy代理,它能把所有的HTTP/FTP请求转发给***。
直接使用yum安装privoxy:
# yum install privoxy
配置privoxy:
# vim /etc/privoxy/config ... listen-address 127.0.0.1:8118 forward-socks5t / 127.0.0.1:1080 . ...
然后启动privoxy:
# privoxy /etc/privoxy/config # ps aux | grep privoxy root 17413 0.0 0.0 17492 1212 ? Ss 18:10 0:00 privoxy /etc/privoxy/config # netstat -an Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 127.0.0.1:8118 0.0.0.0:* LISTEN
可以看到privoxy正在使用8118端口,这个时候privoxy已经在正常运行。
#配置SSH使用代理#
上面已经配置好***的客户端和Privoxy正常运行, 下面对SSH进行配置:
# vim /etc/profile ... 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 # source /etc/profile
这个时候可以可以使用命令来确认是否可以“***”:
# wget www.google.com ... 2018-04-19 18:20:10 (6.00 MB/s) - “index.html” saved [10372]
程序一切正常。