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

SSH Permission Denied

Brian Dannenmueller
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 6, 2022

I set up an SSH key by following the instructions for Mac here: https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/#Set-up-SSH-on-macOS-Linux

After setup, I ran "ssh -T git@bitbucket.org" to test the connection and got the classic "Permission denied (publickey)". So I looked at the troubleshooting section here: 

https://support.atlassian.com/bitbucket-cloud/docs/troubleshoot-ssh-issues/

and none of the scenarios described for my particular error seem to match. As an experiment, I set the same ssh key up with GitHub (which is basically the same process) and the ssh test worked just fine. In addition, I was able to clone a repo on Bitbucket using ssh, even though the connection test never works. What in the world is going on? 

2 answers

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 11, 2022

Hi Brian and welcome to the community.

One possible reason I can think of is that the private key offered when you run ssh -T git@bitbucket.org may be different than the key offered when you clone.

You can see what key is being offered in the first case if you run ssh -Tvvv git@bitbucket.org, the key offered should be shown in the output.

You can create a file named config in your ~/.ssh directory and add the following (if the file exists, just add the following lines):

Host bitbucket.org
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile /Users/Username/.ssh/id_rsa

where /Users/Username/.ssh/id_rsa replace with the path to the private SSH key whose public key is uploaded to Bitbucket, to ensure that this key will be offered.

Kind regards,
Theodora

0 votes
Brant Schroeder
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 6, 2022
Brian Dannenmueller
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 7, 2022

Hi Brant, thanks for your swift reply! Yes, I have seen this page and checked out all of the scenarios, but none seem to apply: 

1) I have verified that my ssh-agent is up and running and my key is loaded

2) I have verified that my key is uploaded to Bitbucket, and can screenshot if necessary. 

3) Git clearly has permission to write to my filesystem, since I've been able to use it to download repos, even with ssh. It's the test command that mysteriously fails.

Like before, issuing the 

ssh -T hg@bitbucket.org

results in the same Permission denied (publickey). Real head scratcher here! 

By the way, I am using a MacBook Pro 2019, Monterey 12.2.1

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events