I have seen a lot of threads with same issue and I followed most of them but none of them resolved my issue. I am using git version 2.3.8 (Apple Git-58) on my mac(OSX 10.10.5). I have a script which clones my repo and deploys it on an EC2 instance. This set-up(script) is well tested and I have previously deployed with the same script multiple times without having any issue. Recently I changed my system and have the above configuration. Now, when I try to run the same(unchanged) script to deploy my application I get
Permission denied (publickey)
- I am able to pull/push to my git repo without any problem.
- I have setup my ssh-key configuration and also I get successful output when I run this command : ssh -T git@github.com
- Since I have deployed the application on the EC2 host previously hence my ssh-keys are in sync on my host and Github (I have cross verified it also).
- I cloned my repo using HTTPS URL while my script has SSH URL, I though it could be the issue and I tried to alter the URLs from SSH to HTTPs**(git remote set-url origin)** also but still did not work and I am still getting permission denied issue.
- I am able to login to my host using the same key which I am using to deploy, so I am assuming it is not an AWS( EC2) issue.
I am pretty sure that the issue has come up because of my changed setup i.e GIT and OS but not able to figure out. After doing a lot of googling and trying a lot of things I am still stuck at this issue.