1

I am new to AWS and followed a tutorial to set up git in aws and the push my local files into it. I have a Key with me with .pem extension which got generated while I was creating the instance. I have added the remote repository like this: git remote add production ssh://[email protected]/var/repo/site.git

after this when I tried to push into the repository I got:

 $ git push production master
Permission denied (publickey).
fatal: Could not read from remote repository.

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

I googled but not able to follow the solutions. However, I could ssh to my instance using:

ssh -i wexpert_instance_2.pem [email protected]

please help.

Suraj Jeswara
  • 446
  • 2
  • 10
  • 23

1 Answers1

0

I tried doing git remote add production ssh://[email protected]/var/repos/site.git

That is expected, because SSH will look for your key in ~/.ssh/id_rsa by default.

Since you don't have a default key, you need to define a ~/.ssh/config file (chmod 644), with:

Host myaws
Hostname ec2-35-154-37-131.ap-south-1.compute.amazonaws.com
User ubuntu
IdentityFile /full/path/to/wexpert_instance_2.pem

Then:

git remote set-url production myaws:/var/repo/site.git
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250