作为程序员,最经常遇到的问题就是无法访问github,这无异于和世界断开连接。
由于http代理可以代理DNS请求,所以不太可能是DNS污染 的问题。
github加速访问两种思路:
VPN加速
warp或者wg转发到墙外(linux 服务器)
之前能访问,但是现在不能访问,可能是wg配置重启掉了。
Proxy in terminal
ssh config linux下通过按照如下修改.ssh/config
设置账号密码,并 ssh -vT [email protected]
,成功后输出Hi Kirrito-k423! You've successfully authenticated, but GitHub does not provide shell access.
。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Host github.com User [email protected] Hostname ssh.github.com PreferredAuthentications publickey ProxyCommand nc -X 5 -x 127.0.0.1:7890 %h %p IdentityFile ~/.ssh/id_rsa Port 443 Host * ControlMaster auto ControlPath /tmp/sshcontrol-%C ControlPersist 1d ServerAliveInterval 30
假如是windows 下,如果安装了git bash,会有connect.exe
的程序
配置如下[^1]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Host github.com User git Port 22 Hostname github.com IdentityFile "C:\Users\Administrator\.ssh\id_rsa" TCPKeepAlive yes ProxyCommand E:\\commonSoftware\\Git\\mingw64\\bin\\connect.exe -S 127.0.0.1:7890 -a none %h %p Host ssh.github.com User git Port 443 Hostname ssh.github.com IdentityFile "C:\Users\Administrator\.ssh\id_rsa" TCPKeepAlive yes
debug ssh clone/push
1 2 3 4 git config --global http.proxy localhost:7890 git config --global http.proxy "http://127.0.0.1:7890" git config --global https.proxy "http://127.0.0.1:7890" GIT_CURL_VERBOSE=1 GIT_TRACE=1 git clone [email protected] :Kirrito-k423/autoUpdateIpconfigPushGithub.git
1 GIT_CURL_VERBOSE=1 GIT_TRACE=1 git clone https://github.com/llvm/llvm-project.git
不同于linux平台的GIT_TRACE=1 git push
,Windows PowerShell 平台应该如下设置:
1 2 3 $env:GIT_CURL_VERBOSE = 1 $env:GIT_TRACE = 1 git push
没使用上指定config
文件,git操作需要明确指定。
1 2 $env :GIT_SSH_COMMAND = 'ssh -F /path/to/your/ssh_config' git push
http代理 There are tons of identical solutions over the internet for defining proxy tunnel for git’s downloads like this one, which all is by setting git’s https.proxy & http.proxy
config. but those answers are not working when you try to clone/push/pull
etc. over the ssh protocol!
For example, by setting git config --global https.proxy socks5://127.0.0.1:9999
when you try to clone git clone [email protected] :user/repo.git
it does not go through the defined sock5
tunnel!
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 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 http.proxy "socks5://127.0.0.1:1080" git config --global https.proxy "socks5://127.0.0.1:1080" git config --global --unset http.proxy git config --global --unset https.proxy vim ~/.ssh/config Host github.com HostName github.com User git ProxyCommand socat - PROXY:127.0.0.1:%h:%p,proxyport=1087 vim ~/.ssh/config Host github.com HostName github.com User git ProxyCommand nc -v -x 127.0.0.1:1080 %h %p
%h %p
是host
和post
的意思
或者
After some visiting so many pages, I finally find the solution to my question:
1 2 3 4 5 6 7 8 9 10 11 12 # [step 1] create a ssh-proxy ssh -D 9999 -qCN [email protected] # [step 2] make git connect through the ssh-proxy # [current script only] export GIT_SSH_COMMAND='ssh -o ProxyCommand="connect -S 127.0.0.1:9999 %h %p"' # OR [git global setting] git config --global core.sshCommand 'ssh -o ProxyCommand="connect -S 127.0.0.1:9999 %h %p"' # OR [one-time only use] git clone -c=core.sshCommand 'ssh -o ProxyCommand="connect -S 127.0.0.1:9999 %h %p"' [email protected] :user/repo.git # OR [current repository use only] git config core.sshCommand 'ssh -o ProxyCommand="connect -S 127.0.0.1:9999 %h %p"'
To install connect on Ubuntu:
1 sudo apt install connect-proxy
ssh代理
Wireguard 代理 post request forward is an all-in-one solution.
1 2 3 4 5 6 7 8 9 10 11 interface: warp public key: fcDZCrGbcpz3sKFqhBw7PtdInygUOtEJfPAs08Wwplc= private key: (hidden) listening port: 51825 peer: bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo= endpoint: [2606:4700:d0::a29f:c001]:1701 allowed ips: 172.16.0.0/24, 0.0.0.0/0, ::/0 latest handshake: 89 days, 23 hours, 15 minutes, 28 seconds ago transfer: 3.51 GiB received, 1.71 GiB sent persistent keepalive: every 25 seconds
latest handshake: 89 days ago
demonstrate wg is done for a long time. At the same time mtr github.com
shows no output prove the bad situation.
STEP1 : first try is to bring the wg-proxy up again
1 2 3 4 python register.py mv warp-helper /etc/defaultvim /etc/config/network ifup warp
and test brainiac machine is back online
常见情形 大文件提交 Sometimes,it‘s the big log fault.
1 2 3 4 5 6 7 8 9 10 11 find . -type f -name "zsim.log.0" -size +10M head -n 10000 your_file.txt | sort | uniq -c | sort -nr | head sed -i '/\[S 0\] WARN: \[6\] ContextChange, reason SIGRETURN, inSyscall 1/d' /staff/shaojiemike/github/PIA_huawei/log/zsim/chai-n/hsti/1000/cpu_tlb/zsim.log.0 find . -type f -name "zsim.log.0" -size +10M -print0 | xargs -0 sed -i '/字符串模式/d' find . -type f -name "zsim.log.0" -size +1M -exec bash -c 'tail -n 2000 "$1" > "$1"_back ' _ {} \;
请求被拦截 1 2 3 4 t00906153@A2305023964 MINGW64 ~/github $ git clone https://github.com/jeremy-rifkin/cpptrace.git Cloning into 'cpptrace' ... fatal: unable to access 'https://github.com/jeremy-rifkin/cpptrace.git/' : SSL certificate problem: self-signed certificate in certificate chain
常见问题
出现于使用https协议,下载大仓库时,出现该错误。
首先使用retry脚本 ,多重试。
脚本中有http下载的限制修改。
使用depth=1
参数,只下载最新提交。之后下好后能适应unshallow
复原
使用更快的https代理。 e.g., 华为xgate使用HK或者Auto
设置mtu解决:
STEP1:
1 2 3 4 5 6 7 8 9 10 eno0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 202.38.73.217 netmask 255.255.255.0 broadcast 202.38.73.255 inet6 fe80::ae1f:6bff:fe8a:e4ba prefixlen 64 scopeid 0x20<link> inet6 2001:da8:d800:811:ae1f:6bff:fe8a:e4ba prefixlen 64 scopeid 0x0<global> inet6 2001:da8:d800:730:ae1f:6bff:fe8a:e4ba prefixlen 64 scopeid 0x0<global> ether ac:1f:6b:8a:e4:ba txqueuelen 1000 (以太网) RX packets 12345942 bytes 2946978044 (2.9 GB) RX errors 0 dropped 1438318 overruns 0 frame 0 TX packets 4582067 bytes 675384424 (675.3 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
STEP2:
STEP3:
1 2 3 4 [root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eno0 MTU=1200 [root@localhost ~]# systemctl restart network
参考文献