We have setup a EC2 build server and would like to use SSH keys to clone the repo.

Steps taken:

cd ~/.ssh
ssh-keygen -t rsa

created config:

host bitbucket.org
 HostName bitbucket.org
 IdentityFile ~/.ssh/bitbucket_rsa
 User git

Loaded public ssh key on bit bucket:

ssh-rsa ...key... ec2_user@ip-censored


git clone https://git@bitbucket.org/user/repo.git

It ask for password. What should we check or do to see where we are going wrong?


You can't clone over HTTPS if you want to use public key authentication. You need to modify the url to the SSH one, like this:

git clone git@bitbucket.org/user/repo.git


git clone ssh://git@bitbucket.org/user/repo.git

should work for you.


It seems you are doing everything right. The problem may be with ssh parameters that you provide. Here is my configuration that works:

Host bitbucket.org
  IdentityFile ~/.ssh/bitbucket.pem
  IdentitiesOnly yes
  StrictHostKeyChecking no

I think the StrictHostKeyChecking no might be the key.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.