参考:GitHub
1.生成 SSH Key
打开Git Bash 或终端,输入以下文本,将示例用的邮箱替换为 GitHub 电子邮件地址。
ssh-keygen -t ed25519 -C "your_email@example.com"
- 当提示
Enter file in which to save the key(/home/name/.ssh/id_ed25519):时,可以按 Enter 键接受默认文件位置,也可以自定义位置和文件名。 - 当提示
Enter passphrase (empty for no passphrase)时,键入安全密码,若直接按Enter表示密码为空。
完成后会生成两个文件(默认文件名):
- id_ed25519
- id_ed25519.pub
2.启动SSH代理并添加SSH Key
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
3.添加 SSH Key 到 GitHub
- 在 GitHub 任意页面的右上角,单击个人资料照片,然后单击
Settings。 - 在边栏的
Access部分中,单击SSH and GPG Keys。 - 单击
New SSH key或Add SSH Key。 - 在
Title字段中,为新密钥添加描述性标签。 - 选择
Key Type为Authentication Key。 - 在
Key字段中,粘贴刚才生成的文件id_ed25519.pub内的内容。 - 单击
Add SSH Key后完成。

被折叠的 条评论
为什么被折叠?



