Permission denied (publickey)
问题
问题描述 :
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
原因
电脑上的公钥没有添加到 GitHub 上 .
解决
## 设置 username
15099@DESKTOP-PI12QV5 MINGW64 ~/Desktop
$ git config --global user.name "lifanyu"
## 设置 email
15099@DESKTOP-PI12QV5 MINGW64 ~/Desktop
$ git config --global user.email "1509984575@qq.com"
## 如果有该文件夹删除如果没有就会出现如下提示
15099@DESKTOP-PI12QV5 MINGW64 ~/Desktop
$ cd ~/.ssh
bash: cd: /c/Users/15099/.ssh: No such file or directory
## 生成 SSH 密钥
15099@DESKTOP-PI12QV5 MINGW64 ~/Desktop
$ ssh-keygen -t rsa -C "1509984575@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/15099/.ssh/id_rsa):
Created directory '/c/Users/15099/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/15099/.ssh/id_rsa.
Your public key has been saved in /c/Users/15099/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:ZFV7w2Bi5jchANze9CRMB/Rk95LwwtSORB423blvsYQ 1509984575@qq.com
The key's randomart image is:
+---[RSA 2048]----+
| ..o.=X+/o...|
| . .=+&o@o+.|
| .oo.=OoO o|
| o. ..oE.* |
| S . +|
| .o|
| . |
| |
| |
+----[SHA256]-----+
## 切换到 .ssh 目录
15099@DESKTOP-PI12QV5 MINGW64 ~/Desktop
$ cd ~/.ssh
## 查看目录中的文件
15099@DESKTOP-PI12QV5 MINGW64 ~/.ssh
$ ls
id_rsa id_rsa.pub
## 打开 id_rsa.pub 文件
15099@DESKTOP-PI12QV5 MINGW64 ~/.ssh
$ vim id_rsa.pub
##内容为 :(自己 id_rsa.pub 中的内容)
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIS0KMOhGlje9usos/lvjqgnRd6miZ1/su/fStgMD65eLAVE1C6FCiowRmLu52UjhNnqhIjRbw4CTCECb7JViuGzLfFb+eq+hD0NQgr/qUuIF3ENrclRMpu63NyhfuB1nDDTTrCd1sHyd1dNReZ8uqwiFckTnJx 15099875@qq.com
id_rsa.pub [unix] (21:02 30/07/2019)
将 id_rsa.pub 中的内容拷贝到 GitHub 上的 settings -> ssh and gpg keys -> new ssh key
再次 push 就成功了 .