git 推送到 github时报权限禁止

xiaoxiao2021-02-28  72

推送流程:

1、建立远程关联,在需要推送的仓库目录下关联github

git remote add origin git@github.com:username/learngit.git

2、开始推送

git push -u origin master

在这里推送是报错了,查看了之后是由于没有公钥和私钥,将本地的推送到远程时,远程服务器需要持有你本地的公钥,所以,首先要在本地生成公钥和私钥,然后把公钥发给远程服务器。

The authenticity of host 'github.com (13.229.188.59)' can't be established. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. RSA key fingerprint is MD5:16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com,13.229.188.59' (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.

3、在本地生成公钥和私钥,查看下本地的ssh密钥,这里的公私钥是我连接我的邮箱生成的。邮箱是我github账户关联的邮箱。执行该命令一直回车即可。由于我之前执行过一次,所以这次我选择了overwrite覆盖。

4、生成后,将id_rsa.pub里面的key添加到github里面。在github界面,点击右上角里面的setting-》SSH and GPG keys-》New SSH key,然后进行添加。

5、添加完key后,重新push一遍。成功。

6、推送后本地和远程的目录情况。

转载请注明原文地址: https://www.6miu.com/read-2627488.html

最新回复(0)