I've recently faced a problem: each time I try to push to git repository (in my case, Bitbucket), I get that error:
$ git push origin master email@example.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
I've found a way to solve it by running these commands:
eval `ssh-agent` ssh-add -l ssh-add ~/.ssh/id_rsa
If I'll do this and then try to
git push origin master, it'll work. But the problem is, this issue starts to appear after some time (probably after reboot, I'm not sure what causes it to appear again). UPD: it's most likely not caused by rebooting, cause I've just faced it 10 minutes after executing the code above, and got the same error. I didn't reboot my laptop since then.
What can cause such a behaviour and how can I fix this?