Search code examples
macosbitbucketssh-keysssh-agent

setting up ssh-keys for bitbucket account (with mac osx)


I have a BitBucket account. Despite setting up the ssh key on the computer and then adding it on my bitbucket account, I fail at connecting:

$ git clone git@bitbucket.org:my-account/myrepo.git 
Cloning into 'myrepo'...
conq: repository does not exist.
fatal: Could not read from remote repository.

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

I did the following:

$ cd ~/.ssh

$ ssh-keygen -f ~/.ssh/my-key -N ''

$ vim config
Host bitbucket.org
  HostName bitbucket.org
  IdentityFile ~/.ssh/my-key

$ ls -l
-rw-------  1 me  ...   229 Jul  8 15:50 config
-rw-------  1 me  ...  1679 Jul  8 14:07 my-key
-rw-r--r--  1 me  ...   411 Jul  8 14:07 my-key.pub

Then I added the content of my-key.pub in my bitbucket account's ssh keys. Then I retried cloning my repository:

$ git clone git@bitbucket.org:my-account/myrepo.git 
Cloning into 'myrepo'...
conq: repository does not exist.
fatal: Could not read from remote repository.

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

I repeated the identical procedure on another machine, it worked:

$ git clone git@bitbucket.org:my-account/myrepo.git
Initialized empty Git repository in /home/me/.ssh/myrepo/.git/
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.

I need to do the same on my first machine now. As a last resort, I followed some advises on the net using the ssh-agent:

$ eval `ssh-agent -s`
$ ssh-add ~/.ssh/my-key

But still no luck:

$ git clone git@bitbucket.org:my-account/myrepo.git 
Cloning into 'myrepo'...
conq: repository does not exist.
fatal: Could not read from remote repository.

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

I have no idea what is different on the first machine, why does it reject my request?


EDIT 1

Of course I tried doing it the very basic way, as suggested by D.Samchuk:

Generating the id_rsa

$ ssh-keygen -t rsa
enterx3

Copied the exact content of the key

$ cat ~/.ssh/id_rsa.pub

And I added id_rsa.pub's content in my BitBucket account's ssh keys.

Git clone will still not allow me to access the repository, whit the same output error message as above.


EDIT 2

I have no idea maybe it is related to mac configurations? Since The other machine is a redhat linux I just wondered but couldn't find any reported similar issue.


Solution

  • Solved. As I delved deeper in the issue I found it is absolutely not related to ssh keys but to missing repository as the error message suggested. It was all about experimenting the global config using git config --global that messed up my git configuration on that computer. I detailed my steps in another thread here: https://unix.stackexchange.com/questions/294780/git-retains-remote-information-from-a-deleted-repository/294809#294809.