Git/代理:修订间差异
来自康健生活
| (未显示同一用户的11个中间版本) | |||
| 第33行: | 第33行: | ||
|} | |} | ||
取消代理 | 并且 ssh 代理还是要区分操作系统。 | ||
参考 https://zhuanlan.zhihu.com/p/481574024 | |||
=== 取消代理 === | |||
{{shc|<syntaxhighlight lang="bash"> | {{shc|<syntaxhighlight lang="bash"> | ||
| 第63行: | 第66行: | ||
[http] | [http] | ||
proxy = socks5://192.168.51.34:1080 | proxy = socks5://192.168.51.34:1080 | ||
proxy = http://192.168.51.34: | proxy = http://192.168.51.34:808 | ||
[https] | [https] | ||
proxy = socks5://192.168.51.34:1080 | proxy = socks5://192.168.51.34:1080 | ||
proxy = | proxy = http://192.168.51.34:808 | ||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
| 第77行: | 第79行: | ||
{{hc|head=~/.gitconfig|output=<syntaxhighlight lang="bash"> | {{hc|head=~/.gitconfig|output=<syntaxhighlight lang="bash"> | ||
[http "https://example.com/"] | [http "https://example.com/"] | ||
http.proxy = | http.proxy = socks5://127.0.0.1:1080 | ||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
{{shc|<syntaxhighlight lang="bash"> | {{shc|<syntaxhighlight lang="bash"> | ||
git config -l --global</syntaxhighlight>|$|/home/kangkk}} | git config -l --global</syntaxhighlight>|$|/home/kangkk}} | ||
== ssh == | |||
ssh 代理,先查看 DNS 解析 | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
nslookup github.com</syntaxhighlight>|<syntaxhighlight lang="text">服务器: unifi.localdomain | |||
Address: 192.168.51.1 | |||
非权威应答: | |||
名称: github.com | |||
Address: 20.205.243.166 | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
=== windows === | |||
配置文件 | |||
{{hc|head=~/.ssh/config|output=<syntaxhighlight lang="bash"> | |||
## github proxy | |||
# | |||
# 别名 | |||
Host github.com | |||
User git | |||
# 目标端口号 | |||
Port 22 | |||
# 目标主机名 | |||
HostName github.com | |||
# 指定的私钥地址 | |||
IdentityFile "C:\Users\kwy\.ssh\id_ed25519" | |||
TCPKeepAlive yes | |||
# git bash 包含 connect.exe | |||
# -S 使用 socket | |||
ProxyCommand "C:\Program Files\Git\mingw64\bin\connect.exe" -S 192.168.51.34:1080 -a none %h %p | |||
Host ssh.github.com | |||
User git | |||
Port 22 | |||
HostName ssh.github.com | |||
IdentityFile "C:\Users\kwy\.ssh\id_ed25519" | |||
TCPKeepAlive yes | |||
ProxyCommand "C:\Program Files\Git\mingw64\bin\connect.exe" -S 192.168.51.34:1080 -a none %h %p</syntaxhighlight>}} | |||
其中 <code>connect -S</code> 指定使用 socket 服务进行代理 | |||
测试联通 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
ssh -T git@github.com</syntaxhighlight>|$|/home/kangkk}} | |||
=== Linux === | |||
{{Linenum|1}} 使用系统内置 nc 命令。 | |||
{{hc|head=/home/kwy/.ssh/config|output=<syntaxhighlight lang="bash"> | |||
Host github.com | |||
User git | |||
Port 22 | |||
Hostname github.com | |||
PreferredAuthentications publickey | |||
IdentityFile "/home/kwy/.ssh/id_ed25519" | |||
TCPKeepAlive yes | |||
ProxyCommand nc -X connect -x 192.168.51.34:808 %h %p | |||
Host ssh.github.com | |||
User git | |||
Port 22 | |||
HostName ssh.github.com | |||
PreferredAuthentications publickey | |||
IdentityFile "/home/kwy/.ssh/id_ed25519" | |||
TCPKeepAlive yes | |||
ProxyCommand nc -X connect -x 192.168.51.34:808 %h %p | |||
</syntaxhighlight>}} | |||
或者使用 socket 服务 <code>ProxyCommand nc -X 5 -x 192.168.51.34:1080 %h %p</code> | |||
{{Linenum|2}} 安装 connect 工具(windows 系统安装 git bash 自带 connect)。 | |||