前言
我重装了系统啥都没了hhhh,然后今天提交的时候报错。
$ git push
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.解决方法
我是在 Windows10 下用 Git Bash 操作的其他平台也差不多。
重新生成 SSH Key。
$ ssh-keygen -t rsa -C GitHub绑定的邮箱$ ssh-keygen -t rsa -C GitHub绑定的邮箱
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/用户名/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/用户名/.ssh/id_rsa
Your public key has been saved in /c/Users/用户名/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:KI0NCK6lOpAvHOT9RPtpobmj3/08V4i+Bbg756Zh8+Q GitHub绑定的邮箱
The key's randomart image is:
+---[RSA 3072]----+
...
+----[SHA256]-----+然后找到这个位置,编辑这个文件,全选然后复制。
/c/Users/用户名/.ssh/id_rsa.pub然后打开 https://github.com/settings/keys
点 New SSH key ,把刚刚 id_rsa.pub 这个文件的内容粘贴进来,保存即可。
