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

3

7

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 [email protected]: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 [email protected]: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 [email protected]: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 [email protected]: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.

Samora answered 8/7, 2016 at 14:16 Comment(2)
I'm voting to close this question as off-topic because it's not about programming. Try apple.stackexchange.comGar
I agree with you sorry for the trouble.Samora
S
0

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.

Samora answered 9/7, 2016 at 10:16 Comment(0)
H
16

just do following:

$ ssh-keygen -t rsa

name: id_rsa

passphrase: just press enter twice to avoid print keyword everytime you connect

$ cat ~/.ssh/id_rsa.pub

copy output

open bitbucket --> profile --> bitbucket settings --> add ssh key --> paste your output

Homestretch answered 8/7, 2016 at 14:25 Comment(2)
That's the very first thing I did, before trying making my own config file, with separate ssh keys. Nonetheless I removed my ssh keys, my ssh config file, I followed your step, git clone wont let me access the repository, same error.Samora
This didn't work. I just followed the official guide support.atlassian.com/bitbucket-cloud/docs/…Healey
H
1

If you are not using a passphrase for the ssh key you shouldn't need the ssh-agent

https://help.github.com/articles/working-with-ssh-key-passphrases/

Haye answered 9/7, 2016 at 10:10 Comment(0)
S
0

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.

Samora answered 9/7, 2016 at 10:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.