'Cannot push to my organization repositories

I've just created a Github organization with two repositories, but It seems that I can't push/pull/fetch to either of them. It displays this error message when I run git push -u origin master:

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

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

Reading a bit about this problem, I've tried this so far:

  1. Created a new ssh key.
  2. Set name and email in git config:
git config --local user.email "[email protected]"
git config --local user.email "myusername"
  1. Created a new ssh-key and added it like this:
ssh-add ~/.ssh/my_ssh_key
  1. Deactivate third-party applications restrictions in the organization settings.

None of this seems to work. The project and the repositories are brand new, and I am just trying to push my initial changes to them.

git init
git add README.md
git commit -m "first commit"
git branch -M master
git remote add origin [email protected]:<organization_name>/repo_name.git
git push -u origin master # here it fails

Any idea about why is not working?

Thanks!

UPDATE: since I have multiple github accounts, running ssh -T [email protected] it displays that I am authenticated other account.

# ssh -T [email protected]
Hi MY_WRONG_ACCOUNT! You've successfully authenticated, but GitHub does not provide shell access.

So I think I need to change that account. (I thought it will change once I run ssh-add ~/.ssh/my_write_acc_key.



Solution 1:[1]

I would create a second key (without passphrase, for testing), and register its public key to the new account.

ssh-keygen -P "" -t rsa -f ~/.ssh/secondUser

And create a ~/.ssh/config file to reference that second key:

Host gh2
  Hostname github.com
  User git
  IdentityFile ~/.ssh/secondUser

From there, check your key does reference the right user with:

ssh -Tv gh2

And change your remote URL:

cd /path/to/repo
git remote set-url origin gh2:<organization_name>/repo_name.git

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 VonC