Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

ssh -T git@bitbucket.org returns logged in as user, but git clone gives Permission denied (publickey

Kaju Bubanja September 30, 2019

The question title says it all. I added my keys under my bitbucket account and as expected I can do ssh -T git@bitbucket.org to get logged in into the server and received the logged in as Satco message. But then when I try to clone a repo where I am admin, for example git clone git@bitbucket.org:Satco/perception.git I get:

13:05:46.735698 exec-cmd.c:237 trace: resolved executable dir: C:/Users/username/AppData/Local/Programs/Git/mingw64/bin
13:05:46.735698 git.c:440 trace: built-in: git clone git@bitbucket.org:Satco/perception.git
Cloning into 'perception'...
13:05:46.782564 run-command.c:663 trace: run_command: unset GIT_DIR; ssh git@bitbucket.org 'git-upload-pack '\''Satco/perception.git'\'''
git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.

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

 

1 answer

0 votes
Rafael Pinto Sperafico
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 30, 2019

Hi @Kaju Bubanja ,

Perhaps the SSH key used to connect to the repository may not be same. Therefore, could you please run the following command reviewing the SSH key used by your clone command:

ssh -v -T git@bitbucket.org

This should provide with:

debug1: Offering public key: ....
debug1: Server accepts key: ...
Enter passphrase for key '....':
debug1: Authentication succeeded (publickey).
Authenticated to bitbucket.org ([18.205.93.0]:22).

Having this information, could you please attempt on issuing the "git clone" command providing the SSH key mentioned in Offering public key?

GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_example -F /dev/null" git@bitbucket.org:Satco/perception.git

The command above will:

  • -i can sometimes be overridden by your config file (e.g ~/.git/config), in which case, you should give SSH an empty config file instead (e.g /dev/null
  • use the SSH key (private) provided, e.g ~/.ssh/id_rsa_example

If you continue on experiencing issues, please enable DEBUG on your Git command to review if the SSH key you are providing is the same one as the one you have on https://bitbucket.org

# on Linux (Terminal / Git Bash)
export GIT_TRACE_PACKET=1
export GIT_TRACE=1
export GIT_CURL_VERBOSE=1
# on Windows (Command Prompt)
set GIT_TRACE_PACKET=1
set GIT_TRACE=1
set GIT_CURL_VERBOSE=1

Kind regards,
Rafael

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events