git的ssh连接github出错
最近用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 | # 启动agent |
测试连接 ssh -T git@github.com
查看本机公钥完整内容 cat ~/.ssh/id_ed25519.pub
- Title: git的ssh连接github出错
- Author: Anrola
- Created at : 2026-08-01 01:24:47
- Updated at : 2026-08-07 00:02:48
- Link: https://redefine.ohevan.com/2026/08/01/git-usage/
- License: This work is licensed under CC BY-NC-SA 4.0.