删除本地~/.ssh目录

C:\Users\MiaoJw\.ssh

设置用户名

1
git config --global user.name "Your Name"

设置邮箱

1
git config --global user.email "email@example.com"

生成key

1
ssh-keygen -t rsa -C "你的邮箱"

打开~/.ssh/id_rsa.pub(win C:\Users\name\.ssh\id_rsa.pub)并复制内容
转到GitHub SSH and GPG keys并创建新的SSH keys,粘贴内容并保存

试验:

1
ssh -T git@github.com

ssh -T git@github.com 如果出现以下问题:

注意: The authenticity of host ‘github.com (20.205.243.166)‘ can‘t be established.

1
2
3
4
The authenticity of host 'github.com (20.205.243.166)' can't be established.
RSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxx.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])?

解决方案为:不要直接enter,根据提示是写入yes再回车。