Permission denied to git repo pushing

Sometimes we have an error like below when we try to push on Github.

image.png

Try to check where is your ssh key is being used by the following command:

 ssh -T -ai ~/.ssh/id_rsa git@github.com

You will get a response like this:

image.png

So, in my case, my ssh key was being used by my other GitHub account. Now you have 2 choices.

  1. Remove ssh key from another account and add it to your account where you are trying to push
  2. Generate a new ssh key and use it.

I did 1st as It was not needed for my other account.