
按下面一步一步来就行配完以后公司内网也能git clone。第一步生成 SSH key终端执行ssh-keygen -t ed25519 -C 你的GitHub邮箱例如ssh-keygen -t ed25519 -C abcgmail.com第二步一路回车会看到Enter file in which to save the key直接回车。然后Enter passphrase你可以直接回车简单或设置密码更安全最终会生成~/.ssh/id_ed25519 ~/.ssh/id_ed25519.pub第三步启动 ssh-agent执行eval $(ssh-agent -s)然后添加 keyssh-add ~/.ssh/id_ed25519第四步查看公钥执行cat ~/.ssh/id_ed25519.pub会输出一长串ssh-ed25519 AAAAC3NzaC1...全部复制。第五步添加到 GitHub打开 GitHubSettings → SSH and GPG keys → New SSH keyTitle 随便写Ubuntu LaptopKey 粘贴刚才内容。点击Add SSH key第六步配置 GitHub 走 443 端口关键因为公司网络屏蔽普通 GitHub HTTPS。创建配置mkdir -p ~/.ssh nano ~/.ssh/config写入Host github.com HostName ssh.github.com User git Port 443保存Ctrl O 回车 Ctrl X第七步设置权限执行chmod 600 ~/.ssh/config chmod 700 ~/.ssh第八步测试 SSH执行ssh -T gitgithub.com第一次会问Are you sure you want to continue connecting输入yes成功结果你会看到Hi xxx! Youve successfully authenticated说明✅ SSH 配置成功✅ 公司网络可用✅ GitHub 可访问第九步clone 测试现在不要再用 HTTPS❌ 不要git clone https://github.com/xxx/xxx.git改成✅ 用 SSHgit clone gitgithub.com:octocat/Hello-World.git以后都用 SSH例如git clone gitgithub.com:你的用户名/项目.git不会再碰 HTTPS TLS 问题。