slacr_

Just to record my life and thoughts.
笔记/编程/杂乱/极简

[Git]配置ssh代理

Nov 7, 2023Git360 words in 2 min

编辑 ~/.ssh/config,

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
ProxyCommand "D:\DevTools\Git\mingw64\bin\connect" -S 127.0.0.1:10808  -a none %h %p


Host github.com
User git
Port 22
Hostname github.com
IdentityFile "C:\Users\28453\.ssh\id_ed25519"
TCPKeepAlive yes

Host ssh.github.com
User git
Port 443
Hostname ssh.github.com
IdentityFile "C:\Users\28453\.ssh\id_ed25519"
TCPKeepAlive yes

# 关于别名
# Host 是别名,HostName 是真正的域名。
# 得益于别名,你可以直接以别名访问地址。例如:
# 无别名: git clone git@github.com:torvalds/linux.git
# 有别名: git clone github:torvalds/linux.git
# 本例中使用与域名一致的别名,以免错误的配置导致登录不上。

# 关于代理
# SOCKS 代理格式: ProxyCommand connect -S localhost:1080 %h %p
# HTTP 代理格式: ProxyCommand connect -H localhost:1080 %h %p
## SSH 代理依赖外部程序,这里使用了 Git for Windows 同捆的 connect.exe。
## Linux 下使用该代理方式需要额外安装 connect-proxy。

# # 我在 GitHub
# Host github.com
# Hostname github.com
# # ProxyCommand connect -H localhost:1080 %h %p
# User git
# PreferredAuthentications publickey
# IdentityFile ~/.ssh/my_github_ed25519

# # 我在 GitLab
# Host gitlab.com
# Hostname gitlab.com
# # ProxyCommand connect -H localhost:1080 %h %p
# User git
# PreferredAuthentications publickey
# IdentityFile ~/.ssh/my_gitlab_ed25519

# # 我在 Gitee
# Host gitee.com
# Hostname gitee.com
# User git
# PreferredAuthentications publickey
# IdentityFile ~/.ssh/my_gitee_ed25519

# # 我在企业
# Host example.com
# Hostname example.com
# Port 22
# User git
# PreferredAuthentications publickey
# IdentityFile ~/.ssh/my_company_ed25519

参考

  1. 设置代理解决github被墙
  • Author:

    slacr_

  • Copyright:

  • Published:

    November 7, 2023

  • Updated:

    November 7, 2023

Buy me a cup of coffee ☕.

1000000