在测试Windows 10的PowerShell下 ssh -T git@github.com命令时,老是报超时。

1
ssh -t git@github.com ssh: connect to host github.com port 22: connection timed out

git 代理

设置 git config --global http.https://github.com.proxy socks5://127.0.0.1:7890
设置完成后, ~/.gitconfig 文件中会增加以下条目:

1
2
[http "https://github.com"]
proxy = socks5://127.0.0.1:7890

ssh 代理

修改 ~/.ssh/config 文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Host github.com
User git
Port 443
Hostname ssh.github.com
IdentityFile "C:\Users\用户名\.ssh\id_rsa"
TCPKeepAlive yes
ProxyCommand "C:\Users\用户名\scoop\apps\git\current\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\用户名\.ssh\id_rsa"
TCPKeepAlive yes
ProxyCommand "C:\Users\用户名\scoop\apps\git\current\mingw64\bin\connect.exe" -S 127.0.0.1:7890 -a none %h %p