git无法关联远程仓库解决方法

问题:

git无法关联到远程仓库,push失败
错误提示如下:

$ git push -u origin master
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

因为之前电脑上有下载过git bash,并且关联过远程仓库。再重新下载软件时提醒报错,无法从远程仓库拉取代码。

解决方法

原因:没有配公钥
步骤:创建SSH Key。在用户主目录下,
$ ssh-keygen -t rsa -C “[email protected]

这样就有了.ssh目录,这个目录下有id_rsa和id_rsa.pub这两个文件

这两个就是SSH Key的秘钥对,id_rsa是私钥,不能泄露出去,id_rsa.pub是公钥,可以放心地告诉任何

人。

第2步:登陆GitHub,打开“Account settings”,“SSH Keys”页面:

然后,点“Add SSH Key”,填上任意Title,在Key文本框里粘贴id_rsa.pub文件的内容

这样即可成功关联远程仓库

总结

每次都要重新配置添加密钥。

你可能感兴趣的:(前端规范)