终端

1
2
export http_proxy=http://user:pwd@proxyAddress:port
export https_proxy=http://user:pwd@proxyAddress:port
1
2
3
4
5
6
export http_proxy=socks5://127.0.0.1:1080 # 配置http 代理访问
export https_proxy=socks5://127.0.0.1:1080 # 配置https 代理访问
export all_proxy=socks5://127.0.0.1:1080 # 配置http和https访问
unset http_proxy # 取消http 代理访问
unset https_proxy # 取消https 代理访问
unset ALL_PROXY # 全部取消

git

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
# 查看代理
git config --global --get http.proxy
git config --global --get https.proxy

# 设置代理
git config --global http.proxy http://127.0.0.1:1080
git config --global https.proxy http://127.0.0.1:1080

# 取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy

# 只对github.com使用代理
git config --global http.https://github.com.proxy socks5://127.0.0.1:7890
git config --global https.https://github.com.proxy socks5://127.0.0.1:7890

# 取消github代理
git config --global --unset http.https://github.com.proxy
git config --global --unset https.https://github.com.proxy

# ~/.ssh/config 内设置
host github.com
# 若使用的是默认端口,设置如下
hostname github.com
# 如果想用443端口,设置如下
# hostname ssh.github.com
# port 443
user git
# 如果是 socks5 代理,取消下面这行注释,并把 1080 改成自己 socks5 代理的端口
# proxycommand nc -x localhost:1080 %h %p
# 如果是 http 代理,取消下面这行注释,并把 6666 改成自己 http 代理的端口
# proxycommand socat - proxy:127.0.0.1:%h:%p,proxyport=6666

curl

1
2
# 编辑 ~/.curlrc 文件,没有就创建
proxy="http://user:pwd@127.0.0.1:1234"