【问题标题】:Github - permission denied to old accountGithub - 旧帐户的权限被拒绝
【发布时间】:2017-05-30 05:32:04
【问题描述】:

面临的问题:
我不能 git push 到我的仓库,错误消息:

remote: Permission to fishercoder1534/Leetcode.git denied to MY_OLD_GITHUB_ACCOUNT
fatal: unable to access 'https://github.com/fishercoder1534/Leetcode.git/': 
The requested URL returned error: 403`

我做过的研究:

  1. 看着这个post,我所有这些都正确指向了我的新 github 帐户: git config --global user.name "NewAccountFirstname NewAccountLastname" git config --global user.email "my_new_github_account_email@gmail.com"
  2. 我已经删除了旧的 ssh 密钥,生成了新的 ssh 密钥,将它们放在 ~/.ssh/ 下,还将它们添加到我的新 Github 帐户中。
  3. 我创建了一个 ~/.ssh/config 文件,其中包含上述帖子所建议的以下内容: Host github.com User git IdentityFile ~/.ssh/id_rsa # wherever your "new" key lives IdentitiesOnly yes
  4. 我已经运行了$ssh -vT git@github.com,它都显示了我的新 Github 帐户信息。 Hi fishercoder1534! You've successfully authenticated, but GitHub does not provide shell access.
  5. 我已经运行了$ssh -i ~/.ssh/id_rsa -vT git@github.com,它还显示了我的新 Github 信息,Hi fishercoder1534! You've successfully authenticated, but GitHub does not provide shell access.

下一个尝试/帮助的选项是什么?

【问题讨论】:

    标签: linux git shell github ssh


    【解决方案1】:

    https url (https://github.com/fishercoder1534/Leetcode.git) 意味着您为 ssh 所做的每项设置都无关紧要。
    而user.name/user.email 与 Git repo 服务器身份验证无关。

    检查您是否已使用 git credential.helper 将您的 https github.com 凭据缓存在凭据管理器中:

    git config credential.helper
    

    这可以解释为什么您的旧帐户一直被使用。
    对于osxkeychain,you can update your account

    或者,当然,您可以切换到 ssh url:

    git remote set-url origin git@github.com:fishercoder1534/Leetcode.git
    

    【讨论】:

    • 没错:git config credential.helper,它返回给我osxkeychain
    • @fishercoder1534 我添加了一个链接供您更新您的 https 凭据。
    • @fishercoder1534 没问题:记住,https 和 ssh 是两种不同的协议:git-scm.com/book/en/v2/… vs. git-scm.com/book/en/v2/…
    猜你喜欢
    • 2013-12-09
    • 2018-08-26
    • 2018-05-08
    • 2012-01-18
    • 2012-04-25
    • 2020-01-08
    • 2011-12-24
    • 2016-02-12
    相关资源
    最近更新 更多