Permission denied when connecting Amazon EC2 with GIT trought SSH

I am using Amazon EC2 instance as dev server and I am trying to git clone my repository from bitbucket to Amazon EC2 instance. What I like to do is add a post hook commit for bitbucket, so any changes made to the repository are automatically reflected in my dev server.

I am connecting a ssh trough to an Amazon EC2 instance, but when I try to git clone a repository, I get the following error:

Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.


I have found many solutions for this problem, but none of them work!

Here's what I've tried so far:

created elastic ip and linked to my instance

-modulate security group to allow incoming network traffic

- download generated pem key from amazon and generate private and public key using puttygen

- uploaded the public key ( and the pem key to my .ssh folder and changed the permissions to 600

- added public key for bitbucket deployment keys

- added public key to authorized_keys file on amazon

-created config file inside .ssh folder and added the following lines inside:

User ubuntu
IdentityFile ~/.ssh/amzon_key.pem


-tried to git clone the repository as root user

I use putty on windows.


source to share

1 answer

Solution by OP.

What I did to get it working:

-deleted config file from .ssh folder

-created new private and public keys using puttygen (dsa - 1024)

- added public key to bitbucket deployment keys

- added public key to amazon authorized_keys file in .ssh folder

- upload keys to .ssh folder and set permissions to 600

-added to the list of known_hosts file in the .ssh folder



All Articles