0

I am on a windows machine trying to push code up to a remote git repository on an ec2 instance which runs ubuntu. I have setup the instance and created a bare repo at a location on the instance.

I have my public key on the instance cos i can ssh to it via putty and also via openssh software i installed.

i checked out

https://serverfault.com/questions/39733/why-do-i-get-permission-denied-publickey-when-trying-to-ssh-from-local-ubunt

git push heroku master Permission denied (publickey)

Git - Permission denied (publickey)

but the suggested solutions were not clear to me

I can ssh into the instance using ssh -i mykey.pem ubuntu@1.1.1.1.

Problem is i have added the repo to my list of remotes but i keep getting the following error when i try to push from my local master to the remote repo using

production - ssh://ubuntu@ec2-1-1-1-1.compute-1.amazonaws.com

git push production master 

Error

Permission denied (publickey).

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.
Joshua Majebi
  • 1,110
  • 4
  • 16
  • 34

1 Answers1

0

I can ssh into the instance using ssh -i mykey.pem ubuntu@1.1.1.1.

This is the problem — you use mykey.pem for ssh but git uses default key. You have to configure ssh so that mykey.pem is the default key for that host:

# .ssh/config
Host ec2-1-1-1-1.compute-1.amazonaws.com
   User ubuntu
   IdentityFile mykey.pem
phd
  • 82,685
  • 13
  • 120
  • 165
  • it appears that changed something in the connection but i am now getting this error when trying the push -- fatal: protocol error: bad line length character: Agen fatal: The remote end hung up unexpectedly – Joshua Majebi Aug 06 '17 at 05:00