linux下使用shadowsocks 做代理
1. 遇到的情况:
在阿里云服务器上需要执行“git clone https://chromium.googlesource.com/v8/v8.git”,然后就访问不到googlesource.com了。。。
2. 工具 —— shadowsocks(包含ssserver/sslocal):
首先,需要一台能够访问到googlesource.com的服务器(用来跑ssserver),执行以下命令安装shadowsocks:
///////////////////////////////////////////////////////////////
为Debian / Ubuntu 安装shadowsocks服务端:
apt-get install python-pip
pip install shadowsocks
为CentOs 安装shadowsocks服务端:
yum install python-setuptools
easy_install pip
pip install shadowsocks
//////////////////////////////////////////////////////////////
然后,在自己需要访问googlesource.com的服务器同样安装shadowsocks,本地代理需要跑sslocal。
3. 配置
- 在跑ssserver的服务器上建配置文件 /etc/shadowsocks/config.json,然后启动执行ssserver。
config.json:
{
"server_port": "sslocal和sssver之间约定的端口",
"password": "sslocal和sssver之间约定的密码",
"method": "加密方式,"bf-cfb", "aes-256-cfb", "des-cfb", "rc4", etc.",
"timeout": "超时时间"
}
- 在跑sslocal的机器(也就是想访问googlesource的本机)上建配置文件 /etc/shadowsocks/config.json,然后执行sslocal。
config.json:
{
"server": "跑ssserver服务器的ip",
"server_port": "跑sssver的端口",
"local_address": "127.0.0.1",
"local_port": "本地https 代理的监听端口"
"password": "与ssserver的password一致",
"method": "与ssserver的method一致",
"timeout": "超时时间"
}
- 给git加上访问本地代理的配置:
执行“git config --global http.proxy 'socks5://127.0.0.1:端口' ”,这里的端口是sslocal的config里面的local_port,
再执行“git config --global https.proxy 'socks5://127.0.0.1:端口' ”。
搞定。
- 最后执行“git config --global --unset-all http.proxy”和“git config --global --unset-all https.proxy”恢复设置。
