9

Windows 下 Git SSH 配置 Socks 代理

 3 years ago
source link: http://misaka.im/index.php/archives/55/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Windows 下 Git SSH 配置 Socks 代理

2020.02.10默认分类 0 评

疫情呆在家里,发现墙又高了不少, Clone Github 仓库时,速度极慢。

$ git clone [email protected]:docsifyjs/docsify.git
Cloning into 'docsify'...
remote: Enumerating objects: 8846, done.
Receiving objects:   1% (89/8846), 44.01 KiB | 1024 bytes/s
Receiving objects:   2% (177/8846), 68.01 KiB | 2.00 KiB/s

使用 SSH 方式安全性更高,不用输入帐户密码,只需配置 SSH keys 即可

如果使用 HTTPS 的连接方式,可以很方便设置 http.proxy

git config --global http.proxy http://127.0.0.1:23333
git config --global --unset http.proxy

而 SSH 的连接需要配置 .ssh 目录下的 config 文件

Host github.com
  User git
  Port 22
  Hostname github.com
  IdentityFile "C:\Users\Mather\.ssh\id_rsa"
  ProxyCommand connect -S 127.0.0.1:23333 -a none %h %p
  TCPKeepAlive yes

Host ssh.github.com
  User git
  Port 443
  Hostname ssh.github.com
  IdentityFile "C:\Users\Mather\.ssh\id_rsa"
  ProxyCommand connect -S 127.0.0.1:23333 -a none %h %p
  TCPKeepAlive yes

看到速度已经起飞

$ git clone [email protected]:docsifyjs/docsify.git
Cloning into 'docsify'...
remote: Enumerating objects: 8846, done.
remote: Total 8846 (delta 0), reused 0 (delta 0), pack-reused 8846
Receiving objects: 100% (8846/8846), 16.68 MiB | 2.21 MiB/s, done.
Resolving deltas: 100% (5639/5639), done.

SSH Proxy Command -- connect.c - wiki

Windows 下 Git SSH 连接方式配置 Socks 代理

git 设置和取消代理

macOS 给 Git(Github) 设置代理(HTTP/SSH


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK