9

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

When:

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?

Michael Hobbs
  • 255
  • 3
  • 8

2 Answers2

9

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

or

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

should work for you.

Jakuje
  • 9,715
  • 2
  • 42
  • 45
0

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.

dtoubelis
  • 4,677
  • 1
  • 29
  • 32