Anrola Lv1

最近用git的ssh连接github总是出问题。
总结一下各种问题的解决方法。


22端口

在C:\Users\用户名.ssh下新建一个无后缀的config文件,里面写入

Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_ed25519
Port 443

其中 IdentityFile ~/.ssh/{是实际认证文件名},上面以id_ed25519为例子。


代理
config加

ProxyCommand connect.exe -S 127.0.0.1:7890 -a none %h %p

127.0.0.1:7890为例子


ssh agent

确认私钥被 ssh-agent 加载

1
2
3
4
5
6
# 启动agent
eval "$(ssh-agent -s)"
# 添加你的私钥
ssh-add ~/.ssh/id_ed25519
# 查看是否加载成功,有一串哈希=正常
ssh-add -l

测试连接 ssh -T git@github.com
查看本机公钥完整内容 cat ~/.ssh/id_ed25519.pub

  • Title:
  • Author: Anrola
  • Created at : 2026-08-01 01:24:47
  • Updated at : 2026-08-01 01:30:38
  • Link: https://redefine.ohevan.com/2026/08/01/git-usage/
  • License: This work is licensed under CC BY-NC-SA 4.0.
On this page