TL;DR
I experienced this when my ssh key went msissing from my ssh agent. I solved the problem by adding it to the ssh agent.
Long answer
I restarted after installing an update on my Macbook. After restaring, first I worked on (and pushed to bitbucket) a personal project. Then I wanted work on my "work" project and push to the appropriate repo. git push
failed this time.
Setting GIT_SSH_COMMAND=ssh -v
helped identify that the ssh key of my personal account was being used. Then I checked the keys added to SSH agent, only my personal account was listed.
$ ssh-add -l
3072 SHA256:xxx...xxx raiyan_kamal (RSA)
I also checked with ssh -T
$ ssh -T
logged in as raiyan_kamal
...
The SSH key for my work account is work_key and name is raiyan@work. So now I added the appropriate key to my agent:
ssh-add <path to my work_key private key file>
Then checked to make sure, both keys were listed:
$ ssh-add -l
3072 SHA256:xxx.xxx raiyan_kamal (RSA)
2048 SHA256:yyy.yyy raiyan@work (RSA)
Now git push
to the work project repo worked.