uniquejava / blog

My notes regarding the vibrating frontend :boom and the plain old java :rofl.
Creative Commons Zero v1.0 Universal
11 stars 5 forks source link

在Terminal中使用梯子的正确方式 #78

Open uniquejava opened 7 years ago

uniquejava commented 7 years ago

啊啊

➜  ~ export ALL_PROXY=socks5://127.0.0.1:1080
➜  ~ brew install watchman

带图形界面的见: https://github.com/shadowsocks/ShadowsocksX-NG https://my.oschina.net/uniquejava/blog/846349

下面是不带GUI的:

  1. 安装pip

wget -c https://bootstrap.pypa.io/get-pip.py python get-pip.py

  1. 安装 sslocal

pip install shadowsocks (可能需要加sudo)

  1. 配置sslocal

vi /etc/shadowsocks.json (ubuntu) vi /usr/local/etc/shadowsocks.json (mac)

{ "server":"SomeCyperVPNServer.com", #可以使用的ss服务器IP "server_port":1035, #ss服务器端口 "local_address": "127.0.0.1", "local_port":1080,#本地端口 "password":"password",#连接ss服务器密码 "timeout":600,#等待超时 "method":"rc4-md5"#加密方式 }

  1. 启动sslocal,并加入开机启动

nohup sslocal -q -c /etc/shadowsocks.json >/dev/null 2>&1 & echo " nohup sslocal -q -c /etc/shadowsocks.json >/dev/null 2>&1 &" >/etc/rc.local

Mac版: 新建~/fq.sh,内容如下: nohup sslocal -q -c /usr/local/etc/shadowsocks.json &

然后chmod +x fq.sh 最后在System Preference>Users中的login items中选择这个脚本加入启动列表或使用前执行一遍./fq.sh开启服务.

  1. 编译安装最新版 proxychains4

git clone https://github.com/rofl0r/proxychains-ng.git --depth 1 cd proxychains-ng ./configure && make && make install && make install-config

  1. 编辑proxychains4配置文件

vim /etc/proxychains.conf 更改 socks4 127.0.0.1 9050为socks5 127.0.0.1 1080

  1. 测试下你的代理

proxychains4 curl https://api.ipify.org/?format=json 如果配置正确,返回你的ss服务器的ip地址

  1. 用proxychain4+git下载

proxychains4 git clone https://github.com/xxxxx/xxxxx.git 报错的话, 前面加sudo就行(最好是将sschains4重新安装到你的home目录下)

  1. 给proxychains4设置别名 打开~/.zshrc(或 .bashrc), 加入alias x=proxychains4 这样在使用时只要x一下就可以翻越GFW从而快速下载开发所需的依赖包. 比如 npm install -g typescript ==> x npm install -g typescript
XoloveStepth commented 7 years ago

这个是什么意思?不用代理?

uniquejava commented 7 years ago

@XoloveStepth 需要,只是开启服务和使用服务都在terminal中进行, 不需要桌面环境.

uniquejava commented 7 years ago

其它情况: alias xsdk ='export http_proxy=socks5://127.0.0.1:1080 && export https_proxy=socks5://127.0.0.1:1080 && sdk'

brew

还有在使用brew的时候必须

ALL_PROXY=socks5://127.0.0.1:1080 brew upgrade

来自:https://github.com/rofl0r/proxychains-ng/issues/109

github

首先安装某不知名软件,然后配置 git 代理

git config --global http.proxy socks5h://localhost:1080
git config --global https.proxy socks5h://localhost:1080

ps: 如果用 socks5 协议,不行就试试 socks5h 协议

来自: https://v2ex.com/t/644874#reply24

others

以下来自https://www.v2ex.com/t/249079

function proxy {
case $1 in
[1-9]*)
export http_proxy=socks5://127.0.0.1:$1
export https_proxy=$http_proxy
git config --global http.proxy $http_proxy
git config --global https.proxy $https_proxy
;;

off)
unset http_proxy
unset https_proxy
git config --global --unset http.proxy
git config --global --unset https.proxy
;;

la|lantern)
export http_proxy=http://127.0.0.1:8787
export https_proxy=$http_proxy
git config --global http.proxy $http_proxy
git config --global https.proxy $https_proxy
;;

ss|shadowsocks)
export http_proxy=socks5://127.0.0.1:1080
export https_proxy=$http_proxy
git config --global http.proxy $http_proxy
git config --global https.proxy $https_proxy
;;

pr|privoxy)
export http_proxy=http://127.0.0.1:8118
export https_proxy=$http_proxy
git config --global http.proxy $http_proxy
git config --global https.proxy $https_proxy
;;

"")
echo usage: proxy [port\|ss\|shadowsocks\|la\|lantern\|off]
;;
esac

echo http_proxy=$http_proxy
echo https_proxy=$https_proxy
}
uniquejava commented 6 years ago

自建vps的教程.

好好学习, 天天向上