1. 打开Git Bash
2. 粘贴以下文本,替换为您的GitHub电子邮件地址
ssh-keygen -t ed25519 -C "your_email@example.com"
# 旧系统不支持Ed25519算法,使用如下命令
# ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
3. 当提示您输入要在其中保存密钥的文件时,请按Enter接受默认文件位置
Enter a file in which to save the key (/c/Users/you/.ssh/id_ed25519):[Press enter]
4. 在提示符下,键入一个安全密码
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
5. 可以通过键入以下命令来更改现有私钥的密码,而无需重新生成密钥对
ssh-keygen -p -f ~/.ssh/id_ed25519
Enter old passphrase: [Type old passphrase]
Enter new passphrase (empty for no passphrase): [Type new passphrase]
Enter same passphrase again: [Repeat the new passphrase]