前言

当我们在新的电脑环境,本地上传到自己的github储存仓库就会出现时密钥不匹配,被拒绝上传。

gitHub报错之git@github.com: Permission denied (publickey). fatal: Could not read from remote repository插图

第一句 git@github.com: Permission denied (publickey). git@github.com:权限被拒绝(公钥)。
从第一句我们可以定位出问题原因所在。github中的SSH问题
第二句报错: fatal: Could not read from remote repository. 致命:无法从远程存储库读取。

解决办法
第一步setting —>SSH and GPG keys
gitHub报错之git@github.com: Permission denied (publickey). fatal: Could not read from remote repository插图1
第二
gitHub报错之git@github.com: Permission denied (publickey). fatal: Could not read from remote repository插图2
第三
在文件中打开git Bash

输入命令ssh-keygen -t rsa -C
再次输入 cat ~/.ssh/id_rsa.pub
gitHub报错之git@github.com: Permission denied (publickey). fatal: Could not read from remote repository插图3
复制粘贴到第二部 New SSH key
填入key中即可
添加成功
git push -u origin master
最后Github上面的key创建完成后就可以执行git push --set-upstream origin master这条指令了
就没问题了

PS:如果本机host文件中访问gitHub中使用外网ip访问,那么必须得删掉才能正常上传不然会出现
ssh_dispatch_run_fatal: Connection to xxxxxxx port 22: Software caused connection abort问题

快去搞起自己的私人小仓库吧~

原文链接:https://blog.csdn.net/weixin_42164539/article/details/105835259

本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《gitHub报错之git@github.com: Permission denied (publickey). fatal: Could not read from remote repository
   

还没有人抢沙发呢~