由于想搭服务器整那个screeps然后顺便出一期教程,解决服务器git clone请求失败的问题
1. 生成SSH密钥对
打开终端(Windows用户使用Git Bash或WSL),执行以下命令生成密钥:
ssh-keygen -t ed25519 -C "your_email@example.com"
2. 添加公钥到GitHub
- 复制公钥内容:
cat ~/.ssh/id_ed25519.pub # 选中输出内容并复制
- Windows用户也可用文本工具(如Notepad)打开`C:\Users\你的用户名\.ssh\id_ed25519.pub`。
在GitHub中添加公钥:
登录GitHub → 点击右上角头像 → Settings → SSH and GPG keys → New SSH key。
Title:自定义名称(如“My Laptop”)。
Key type:保持默认Authentication Key
。
Key:粘贴复制的公钥内容。
点击 Add SSH key 完成添加。
以防你太聪明,这里给你个配图好了。






3. 测试SSH连接
运行以下命令测试连通性:
ssh -T git@github.com
成功响应
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
(ps: 筑波之前有过响应失败的案例但是这次一次就成功了)