这个问题出现的原因是本机未与github账号作秘钥匹配,生成本地公钥添加至远程即可
1 右键打开gitbash,测试连通性,可以看出是公钥问题
$ ssh -T git@github.com
Permission denied (publickey).
2 生成公钥,一路回车即可
ssh-keygen -t rsa -C "youraccount"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/liubin52/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/liubin52/.ssh/id_rsa.
Your public key has been saved in /c/Users/liubin52/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:kFQ7zM46AtngvtdAwWMmujvcMLdO7j95vE2raKLEQiM xichengxml
The key's randomart image is:
+---[RSA 2048]----+
| . ... |
| . *. + . |
| ..+ oo = |
|.. +. + . |
|E++.. S |
|=+.o. . |
|o+*.oo= . |
|=.o=.=o+o . |
| o==+ooooo |
+----[SHA256]-----+
3 切换到秘钥生成目录,在生成秘钥的结果上可以看到秘钥存放位置
liubin52@JRA19C2370FEE8 MINGW64 /d/user
$ cd /c/Users/liubin52/.ssh/
liubin52@JRA19C2370FEE8 MINGW64 ~/.ssh
$ ls
id_rsa id_rsa.pub known_hosts
4 查看公钥文件数据
$ cat id_rsa.pub
5 复制公钥内容,添加进github公钥列表,具体怎么添加可以百度,添加完成后校验是否成功
$ ssh -T git@github.com
Hi xichengxml! You've successfully authenticated, but GitHub does not provide shell access.
看到如图结果表示连接成功。
注意:校验是使用的是git@github.com,不是自己的账号