git 代理配置
github 在国内访问一直不是很稳定,clone/push 等操作速度很慢。以下提供 https 和 ssh 这两种的访问方式的加速方法的配置,以及优缺点比较。
https
github 允许用户通过 https 端口使用 ssh,可以通过下面的指令测试
ssh -T -p 443 [email protected] Hi username! You've successfully authenticated, but GitHub does not provide shell access.
如果测试不通过,就需要修改配置文件 ~/.ssh/config,增加
Host github.com Hostname ssh.github.com Port 443
优点
http和https代理是非常常见的,比如我一般都是对系统全局代理- 配置比较简单
缺点
- 因为走的是
https协议,那么在github认证时只能使用提供 username/password 的方式认证,如果要避免每次push时都输入密码,需要一些额外的步骤。Caching your GitHub password in Git - User Documentation - 另外如果开启了
two-factor authentication,还需要提供personal access token。Provide access token if 2FA enabled - User Documentation
更多详情参考 Using SSH over the HTTPS port - User Documentation
ssh
前提:需要一个 socks5 代理
如果是直接通过 ssh 协议访问,则需要按照以下步骤配置
在 /usr/local/bin 增加一个文件,名为 git-proxy-wrapper,增加 +x 权限
ruhm@mac:~$ cat /usr/local/bin/git-proxy-wrapper #! /bin/bash nc -xlocalhost:1080 -X5 $*
注意,上面需要本机在 1080 端口打开 socks5 代理,端口可以自定义
~/.ssh/config 配置文件中内容如下
Host github.com
hostname github.com
User xxxxx
IdentityFile ~/.ssh/xxxxxx
ProxyCommand /usr/local/sbin/git-proxy-wrapper '%h %p'优点
- ssh 认证不需要提供用户名和密码
缺点
- 需要一个
socks5代理
refs
相关推荐
projava 2020-11-14
WanKaShing 2020-11-12
airfish000 2020-09-11
tryfind 2020-09-14
yegen00 2020-09-10
kkaazz 2020-09-03
风语者 2020-09-02
BraveWangDev 2020-08-19
lichuanlong00 2020-08-15
gsl 2020-08-15
pandaphinex 2020-08-09
yhuihon 2020-08-09
CheNorton 2020-08-02
xiangqiao 2020-07-28
hpujsj 2020-07-26
hpujsj 2020-07-26
sshong 2020-07-19
BraveWangDev 2020-07-19
annan 2020-07-18