Why am I not able to add an SSH key in Bitbucket Cloud
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
This article covers how to resolve "already registered" or "keys must be unique" error messages when adding an SSH key.
Diagnosis
Review the exact error message you receive when adding the SSH key:
Someone has already registered that SSH key.
SSH keys must be unique and deleted keys may take up to 30 days to be removed. Please use a unique SSH key.
Cause
The error indicates that the SSH key you are trying to add is already in use by another Bitbucket account, workspace, a repo's access keys, or a project's access keys.
An SSH key that has been added to an account or a workspace can't be added to another account or workspace, or as an access key of a repository or a project. Identifying the authenticated user who performs a specific action must be unique.
An SSH key that has been added as an access key to a repo or a project can also be added to the access keys of other repos or projects. However, it can't be added to a Bitbucket account or workspace.
Solution
Solution 1 - Recommended
Create a new SSH Key pair following the steps in one of the articles in Set up an SSH key.
After its creation, you can add the public key:
to your account's SSH keys
to the SSH keys of a workspace (from Workspace settings > SSH keys)
to the access keys of a repository (from Repository settings > Access keys)
to your project's access keys (from Project settings > Access keys
We highly recommend this option due to the slight possibility that the SSH private key has leaked. You can recover the public key with the private key alone.
Solution 2
Check if the public SSH key you want to use has been added to any of these places:
Any other Bitbucket accounts you may own. If you have multiple Bitbucket accounts with different email addresses, log in to each account and check its SSH keys on this page.
The SSH keys of the workspaces you administer. You need admin access to a workspace to view its SSH keys. If you don't, you can ask an admin to check.
After logging in to https://bitbucket.org/, select your avatar (top right corner) > select All workspaces. You will see a list of all workspaces your account has access to, and the link Manage for each workspace you administer. For each workspace you administer, select the link Manage and then select SSH keys from the left sidebar.
The Access keys of the repositories you have access to. You need to have admin permissions on the repo to check this. If you don't, ask an admin to check.
While viewing a repository on Bitbucket Cloud's website, select Repository settings from the left sidebar and then Access keys from the new left sidebar.
The Access keys of any Bitbucket projects you have access to. You need to have admin permissions on the project to check this. If you don't, ask a project or workspace admin to check.
You can find a list of all workspaces your account has access to here: https://bitbucket.org/account/workspaces/. Open each workspace from the list and select Projects from the top menubar. Open each project from the list, select Project settings from the left sidebar, and then select Access keys from the new left sidebar.
If you can locate where this SSH key has been added, you will need to remove it to reuse it. An Access key needs to be removed from all repos and projects where it has been added so that it can be added to an account or a workspace.
If you can't figure out where the key is added, you can visit our support portal, create a support ticket, and attach the content of the public SSH key to the newly created ticket. If the key is registered to a user, project, or repo in your workspace, we may be able to provide you with information about where this key was added. Otherwise, see Solution 1.
Was this helpful?