首页 > 解决方案 > SSH 密钥在 github 中添加了读/写,但仍然被拒绝权限

问题描述

所以我多年来一直在使用 GitHub,没有任何问题。今天刚好碰到第一个。我创建了一个新帐户,创建了一个新存储库,然后克隆并提交到存储库。基本上,我目前的 GitHub 存储库中有内容。

但是,刚才我尝试使用git commit -am "Updated."并运行了一个简单的代码git push origin master来提交我的更改,我遇到了这个错误:

[user:.../scripts/ptscripts]$ git push origin master                                                              12:01PM/05.13
ERROR: Permission to my-github-user/ptscripts.git denied to [obfuscated user].
fatal: Could not read from remote repository.

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

我不明白为什么我会收到这个错误。我的公共 SSH 密钥已添加到我的 GitHub 帐户中,并显示为读/写。[被混淆的用户]。但是,属于另一个 GitHub 用户帐户,所以我不太确定它为什么要尝试使用旧用户帐户。

我最近做的唯一一件事就是将权限~/.config从 root 更改为我的用户帐户,以抑制有关权限被拒绝的警告。除此之外,我没有改变任何东西。

任何建议将不胜感激。

标签: git

解决方案


您似乎没有更改 github.com 的 SSH 密钥。GitHub 通过使用的 SSH 密钥来区分用户。

~/.ssh/config换键方便。我对 github.com 的配置是这样的。

Host github.com
  user git
  IdentityFile ~/.ssh/set0gut1.key
#  IdentityFile ~/.ssh/old-account.key

推荐阅读