Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
286 views
in Technique[技术] by (71.8m points)

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

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.

question from:https://stackoverflow.com/questions/65559538/multiple-github-accounts-on-linux-cannot-push-to-remote-but-can-pull

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...