It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

setting up bitbucket ssh keys on ubuntu

Jared Nagle Apr 14, 2014

Hi There,

I have been following the documentation on setting up ssh access to bitbucket.organd cannot seem to authenticate to the server.

I have created the id_rsa from openssl v1.0.1e and have copy-pasted id_rsa.pub to the key store through account management, However even after adding the key via ssh-add and starting the ssh-agent (/bin/bash), I cannot clone one of my repositories. Could you please let me know how to resolve this if this is a common issue.

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

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

Sincerely,

Jared.

6 answers

1 accepted

0 votes
Answer accepted
Jani Hurskainen Apr 21, 2014

You are executing the commands as different user when sudoing.

This is the normal user command and it is using normal user's ssh keys:

ssh -T git@bitbucket.org

when sudoing you're not using the normal user's ssh keys but root user instead:

sudo git clone

One possible workaround is to give the normal user rights to work in the /usr/local-directory. Below I have created a project specific subdirectory that is owned by localuser.

sudo mkdir /usr/local/src/<project>
sudo chown localuser.localuser /usr/local/src/<project>
cd /usr/local/src/
git clone <repo_url> <project>

1 vote
Tiago Comasseto Apr 14, 2014

Hi Jared, try this command: ssh -T hg@bitbucket.orgIf you get a response like "logged in as username.

You can use git or hg to connect to Bitbucket. Shell access is disabled."

The ssh keys were configured correct and the problem may be something else, otherwise you may need to review your keys.

Cheers

Jani Hurskainen Apr 15, 2014

The question is tagged as git so I guess the correct command is

ssh -T git@bitbucket.org

right ?

Jim Redmond Atlassian Team Dec 27, 2017

It doesn't matter - you can use "git", "hg", or your username. It's just for testing.

0 votes
Jared Nagle Apr 16, 2014
Yes I got 'logged in as thenaglecode' so it must be something else.
0 votes
Rafael Sperafico Atlassian Team Apr 16, 2014

Hi Jared,

The key you've uploaded to Bitbucket might have a different fingerprint.

Can you try deleting it and adding it in again, please?

Kind regards,

Rafael

0 votes
Jared Nagle Apr 19, 2014

hi there, This is still my output :(

localuser@myserver:/usr/local/src$ ssh -T git@bitbucket.org
logged in as myusername.

You can use git or hg to connect to Bitbucket. Shell access is disabled.
localuser@myserver:/usr/local/src$ sudo git clone git@bitbucket.org:myusername/autumn-education.git
Cloning into 'autumn-education'...
Permission denied (publickey).
fatal: Could not read from remote repository.

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

0 votes
Jared Nagle Apr 19, 2014

Hi there,

I just successfully cloned the repository i was after into my own home directory. Turns out it was a matter of user permissions and the root home dir being searched for the private key because i used sudo. At least this is what i am assuming is the cause.

In conclusion, the solution was to clone the repo into my home directory and the key was correctly picked up. :)

I Guess that i could give my regular user rwx on /usr/local/src if i wanted... but this is the solution for now.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

1,731 views 1 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you