linux 上的多个 github 帐户 - 不能推送到远程,但可以拉

问题描述

我按照本文中的说明在我的 ubuntu 机器上设置了多个 GitHub 帐户:https://www.freecodecamp.org/news/manage-multiple-github-accounts-the-ssh-way-2dadc30ccaca/

我可以从存储库中拉取,但无法推送。我不断收到拒绝访问错误

ERROR: Repository not found.
fatal: Could not read from remote repository.

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

这是我的 ssh 配置的样子:

Host github.com  
    HostName github.com
    IdentityFile ~/.ssh/github
    IdentitiesOnly yes
    Port 22

Host cloudcountry.github.com  
    HostName github.com
    IdentityFile ~/.ssh/id_rsa_cloudcountry
    User git
    IdentitiesOnly yes
    Port 22

Host gitlab.com  
    HostName bitbucket.org/
    IdentityFile ~/.ssh/cloudsun_id_rsa
    IdentitiesOnly yes
    Port 22

这些是 git 遥控器 git remote -v

origin  git@cloudcountry.github.com:cloudcountry/repo-name.git (fetch)
origin  git@cloudcountry.github.com:cloudcountry/repo-name.git (push)

不确定我可能遗漏了什么。

解决方法

你应该:

  • 测试您的 URL 以查看身份验证是否成功:

      ssh -Tv git@cloudcountry.github.com
    
  • 冲洗检查存储库 URL。
    例如:https://github.com/cloudcountry 不存在(并且通过扩展,https://github.com/cloudcountry 下的任何存储库都不会存在/可访问,无论使用什么私有 SSH 密钥)