0

When i try cloning public repository hosted on bitbucket using SSH it fails, for instance when i try cloning the following git repository

git clone git@bitbucket.org:tildeslash/monit.git

It gives me this error

Cloning into 'monit'...
Permission denied (publickey).
fatal: Could not read from remote repository.

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

However, when i try cloning the same repo using HTTPS

git clone https://npmtechnologies@bitbucket.org/tildeslash/monit.git

It works, what could be the possible issue?

Ibrahim Azhar Armar
  • 25,288
  • 35
  • 131
  • 207
  • 1
    Go to your profile settings on bitbucket. Check under authentication (or similar) tab. There should be something mentioned about adding your public SSH key there. – hjpotter92 Sep 20 '15 at 10:48
  • Do we require SSH key for a public repo? it still doesn't make sense because if it requires SSH key it must not allow cloning using HTTPS which is happening in my case. – Ibrahim Azhar Armar Sep 20 '15 at 10:49
  • @hjpotter92 you are right, by adding SSH key it did work, thank you :-) – Ibrahim Azhar Armar Sep 20 '15 at 11:02

1 Answers1

1

https and ssh are two different protocols.

The fact that your public key might not be properly registered in your Bitbucket account has nothing to do with the https url, which will work.

if it requires SSH key it must not allow cloning using HTTPS

No: each public repo can be accessed either by ssh or https. One is no more "mandatory" than the other.
If ssh does not work, https will.
Https will require a password only when pushing.
ssh requires that your public key is registered in your Bitbucket account for establishing an authenticated connection.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250