当前位置:首页>java>AI编程二次创作,GitHub SSH 配置完整流程(Windows + PowerShell 笔记版建议收藏)

AI编程二次创作,GitHub SSH 配置完整流程(Windows + PowerShell 笔记版建议收藏)

  • 2026-10-21 13:28:46
AI编程二次创作,GitHub SSH 配置完整流程(Windows + PowerShell 笔记版建议收藏)

目标:
让本地电脑可以“免密码、安全地”访问 GitHub(clone / push / pull)


一、确认 Git 是否安装成功

1️⃣ 查看 Git 版本

git --version

✅ 正确结果示例:

git version 2.xx.x.windows.x

如果提示不是命令 → 说明 Git 没装或没加 PATH。


二、配置 Git 的用户名和邮箱(用于提交记录)

这一步不影响 SSH 是否能连,但必须做,否则以后 commit 会报错。

2️⃣ 设置用户名

git config --global user.name "你的GitHub用户名"

3️⃣ 设置邮箱(建议和 GitHub 一致)

git config --global user.email "你的邮箱@gmail.com"

4️⃣ 检查是否配置成功

git config --global --list

看到:

user.name=xxx

user.email=xxx

即成功。


三、生成 SSH Key(最关键的一步)

SSH Key = 本地电脑的“身份证”
GitHub 用它来识别你是谁

5️⃣ 生成 ed25519 类型的 SSH Key(推荐)

ssh-keygen-t ed25519 -C"你的邮箱@gmail.com"

接下来会有 3 个提示:

Enter file in which to save the key:

👉 直接回车(用默认路径)

Enter passphrase:

👉 直接回车(新手可先不设密码)

Enter same passphrase again:

👉 再回车

6️⃣ 成功标志

看到类似:

Your identification has been saved in C:\Users\xxx\.ssh\id_ed25519Your public key has been saved in C:\Users\xxx\.ssh\id_ed25519.pub

说明 SSH Key 已成功生成。


四、复制 SSH 公钥(⚠️ 只能复制 .pub)

7️⃣ 查看并复制公钥

type$env:USERPROFILE\.ssh\id_ed25519.pub

输出一整行,类似:

ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... your@email.com

👉 整行复制(不要多、不要少)


五、把 SSH Key 添加到 GitHub

8️⃣ GitHub 操作路径

  1. GitHub → 右上角头像

  2. Settings

  3. SSH and GPG keys

  4. 点击 New SSH key

9️⃣ 填写

  • Title:随便(如 windows-laptop / 学习用)

  • Key:粘贴刚刚复制的那一整行公钥

  • 点击 Add SSH key

看到 Key 出现在列表中 → 成功。


六、测试 SSH 是否真的打通(非常重要)

🔟 测试连接

ssh -T git@github.com

第一次连接会看到:

Are you sure you want to continue connecting (yes/no)?

👉 输入:

yes

✅ 正确的最终成功标志

Hi Haven-CC! You've successfully authenticated, but GitHub does not provide shell access.

看到这句话 = SSH 完全打通(100%)


七、之后如何使用(你现在已经具备的能力)

✅ 用 SSH clone 项目

git clone git@github.com:用户名/仓库名.git

例如:

git clone git@github.com:punkpeye/awesome-mcp-servers.git

以后你可以:

  • clone 任意开源项目

  • push 自己的修改

  • 做 AI 编程二次创作

不再需要输账号密码。

如果对你有帮助可以点点爱心,你的支持是我最大动力,也欢迎加我一起交流

最新文章

随机文章