Permission denied error occurring while connecting to SSH even though the public/private keys are added correctly

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

  • This article provides instructional steps for verifying if the public/private keys are added correctly for SSH authentication, and troubleshooting steps for a potential username issue

Summary

  • When authenticating via SSH, you receive an SSH Permission Denied Error even though the public/private keys are added correctly:

1 2 3 git%2520clone%2520git@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

Solution

  • Firstly, verify the private key that is loaded into SSH Agent:

    1 ssh-add -l
  • If the key is not loaded, add the private key to SSH agents.

    ℹ️ id_rsa is the name of the private key. If the name of the private key is different, replace it accordingly.

    1 ssh-add ~/.ssh/id_rsa
  • If the issue persists, verify the username by executing the following command:

1 whoami
  • It is possible that if the username contains some URL-encoded special strings, this could be the cause of the issue

    Example:

1 git%2520clone%2520git@bitbucket.org: Permission denied (publickey).

In this example, git%2520clone%2520git was the username. If the username contains some special characters, change the username accordingly without any special encoded strings.

If the above instructions do not assist in resolving the issue, please raise a support ticket or raise a community support ticket for further assistance with this.

Updated on April 2, 2025

Still need help?

The Atlassian Community is here for you.