multiple github accounts on linux - cannot push to remote, but can pull

Viewed 47

I set up multiple GitHub accounts on my ubuntu machine following the instructions in this article: https://www.freecodecamp.org/news/manage-multiple-github-accounts-the-ssh-way-2dadc30ccaca/.

I am able to pull from the repository, but I cannot push. I keep getting the access denied error:

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

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

Here is what my ssh config looks like:

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

These are the git remotes git remote -v

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

Not sure what I might be missing.

1 Answers

You should:

  • test your URL in order to see if the authentication succeeds:

      ssh -Tv git@cloudcountry.github.com
    
  • douche-check the repo URL.
    For instance: https://github.com/cloudcountry does not exist (and by extension, no repository under https://github.com/cloudcountry would exist/be accessible, no matter the private SSH key used)

Related