公司内网 git clone提示fatel失败
按下面一步一步来就行,配完以后公司内网也能git clone。
第一步:生成 SSH key
终端执行:
ssh-keygen -t ed25519 -C "你的GitHub邮箱"例如:
ssh-keygen -t ed25519 -C "abc@gmail.com"第二步:一路回车
会看到:
Enter file in which to save the key直接回车。
然后:
Enter passphrase你可以:
直接回车(简单)
或设置密码(更安全)
最终会生成:
~/.ssh/id_ed25519 ~/.ssh/id_ed25519.pub第三步:启动 ssh-agent
执行:
eval "$(ssh-agent -s)"然后添加 key:
ssh-add ~/.ssh/id_ed25519第四步:查看公钥
执行:
cat ~/.ssh/id_ed25519.pub会输出一长串:
ssh-ed25519 AAAAC3NzaC1...全部复制。
第五步:添加到 GitHub
打开 GitHub:
Settings → 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 git@github.com第一次会问:
Are you sure you want to continue connecting输入:
yes成功结果
你会看到:
Hi xxx! You've successfully authenticated说明:
✅ SSH 配置成功
✅ 公司网络可用
✅ GitHub 可访问
第九步:clone 测试
现在不要再用 HTTPS:
❌ 不要:
git clone https://github.com/xxx/xxx.git改成:
✅ 用 SSH:
git clone git@github.com:octocat/Hello-World.git以后都用 SSH
例如:
git clone git@github.com:你的用户名/项目.git不会再碰 HTTPS TLS 问题。
